Actually wait while the first in reconnects

This commit is contained in:
Gavin M. Roy 2020-07-07 16:21:01 -04:00
parent ecc070e974
commit a1736bccae

View file

@ -344,9 +344,12 @@ class ApplicationMixin:
message = str(err) message = str(err)
if isinstance(err, psycopg2.OperationalError) and _attempt == 1: if isinstance(err, psycopg2.OperationalError) and _attempt == 1:
LOGGER.critical('Disconnected from Postgres: %s', err) LOGGER.critical('Disconnected from Postgres: %s', err)
retry = True
if not self._postgres_reconnect.locked(): if not self._postgres_reconnect.locked():
async with self._postgres_reconnect: async with self._postgres_reconnect:
if await self._postgres_connect(): retry = await self._postgres_connect()
if retry:
await self._postgres_connected.wait()
async with self.postgres_connector( async with self.postgres_connector(
on_error, on_duration, timeout, on_error, on_duration, timeout,
_attempt + 1) as connector: _attempt + 1) as connector: