Closed
Changes from 1 commit
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Failed to load files.
PrevPrevious commit
Adds setting to disable max_consecutive_exceptions
  • Loading branch information
egalpin committedJan 31, 2018
commit 79317dcc159665f52dabe542d9abc01539182c09
Original file line numberDiff line numberDiff line change
Expand Up@@ -1372,10 +1372,12 @@ async def _do_execute(self, query, executor, timeout, retry=True):
return result, stmt

async def _maybe_close_bad_connection(self):
self._consecutive_exceptions += 1
if self._consecutive_exceptions > \
self._config.max_consecutive_exceptions:
await self.close()
if self._config.max_consecutive_exceptions > 0:
self._consecutive_exceptions += 1

if self._consecutive_exceptions > \
self._config.max_consecutive_exceptions:
await self.close()


async def connect(dsn=None, *,
Expand All@@ -1387,7 +1389,7 @@ async def connect(dsn=None, *,
statement_cache_size=100,
max_cached_statement_lifetime=300,
max_cacheable_statement_size=1024 * 15,
max_consecutive_exceptions=5,
max_consecutive_exceptions=0,
command_timeout=None,
ssl=None,
connection_class=Connection,
Expand DownExpand Up@@ -1447,7 +1449,7 @@ async def connect(dsn=None, *,
:param int max_consecutive_exceptions:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably important to allow users to disable this, ie. by sending 0 in the same way as many of the rest of these parameters.

@asyncpg/maintainers: personally, I think the default of 5ish is pretty reasonable here, but depending on your preference in backwards-compatibility we might want to default this to 0 for now behavior change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea with 0 setting

the maximum number of consecutive exceptions that may be raised by a
single connection before that connection is assumed corrupt (ex.
pointing to an old DB after a failover)
pointing to an old DB after a failover). Pass ``0`` to disable.

:param float command_timeout:
the default timeout for operations on this connection
Expand Down