Skip to content

Commit

Permalink
added the increment
Browse files Browse the repository at this point in the history
  • Loading branch information
dwjorgeb authored Feb 27, 2023
1 parent 5f27417 commit 899b75c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions django_dbconn_retry/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def ensure_connection_with_retries(self: django_db_base.BaseDatabaseWrapper) ->
else:
_log.info("Database connection failed. Refreshing...")
# mark the retry
self._connection_retries = 1
if not hasattr(self, "_connection_retries"):
self._connection_retries = 0

self._connection_retries += 1
# ensure that we retry the connection. Sometimes .closed isn't set correctly.
self.connection = None
del self._in_connecting
Expand All @@ -70,8 +73,7 @@ def ensure_connection_with_retries(self: django_db_base.BaseDatabaseWrapper) ->
self.ensure_connection()
post_reconnect.send(self.__class__, dbwrapper=self)
else:
_log.debug("Database connection failed, but not due to a known error for dbconn_retry %s",
str(e))
_log.debug("Database connection failed, but not due to a known error for dbconn_retry %s", str(e))
del self._in_connecting
raise
else:
Expand Down

0 comments on commit 899b75c

Please sign in to comment.