mirror of
https://github.com/sprockets/sprockets-postgres.git
synced 2024-12-28 19:29:21 +00:00
Actually wait while the first in reconnects
This commit is contained in:
parent
ecc070e974
commit
a1736bccae
1 changed files with 9 additions and 6 deletions
|
@ -344,14 +344,17 @@ 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()
|
||||||
async with self.postgres_connector(
|
if retry:
|
||||||
on_error, on_duration, timeout,
|
await self._postgres_connected.wait()
|
||||||
_attempt + 1) as connector:
|
async with self.postgres_connector(
|
||||||
yield connector
|
on_error, on_duration, timeout,
|
||||||
return
|
_attempt + 1) as connector:
|
||||||
|
yield connector
|
||||||
|
return
|
||||||
message = 'disconnected'
|
message = 'disconnected'
|
||||||
exc = on_error('postgres_connector', ConnectionException(message))
|
exc = on_error('postgres_connector', ConnectionException(message))
|
||||||
if exc:
|
if exc:
|
||||||
|
|
Loading…
Reference in a new issue