From 4f60c7bf0a199f0802ea2ab1504c4a30fa395c2f Mon Sep 17 00:00:00 2001 From: "Gavin M. Roy" Date: Wed, 8 Jul 2020 14:33:04 -0400 Subject: [PATCH] Delay the initialization of asyncio objects to on_start --- VERSION | 2 +- sprockets_postgres.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 3a3cd8c..1892b92 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.1 +1.3.2 diff --git a/sprockets_postgres.py b/sprockets_postgres.py index ebebf12..07278fb 100644 --- a/sprockets_postgres.py +++ b/sprockets_postgres.py @@ -290,8 +290,8 @@ class ApplicationMixin: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._postgres_pool: typing.Optional[pool.Pool] = None - self._postgres_connected = asyncio.Event() - self._postgres_reconnect = asyncio.Lock() + self._postgres_connected: typing.Optional[asyncio.Event] = None + self._postgres_reconnect: typing.Optional[asyncio.Lock] = None self._postgres_srv: bool = False self.runner_callbacks['on_start'].append(self._postgres_on_start) self.runner_callbacks['shutdown'].append(self._postgres_shutdown) @@ -480,6 +480,9 @@ class ApplicationMixin: callback mechanism. """ + self._postgres_connected = asyncio.Event() + self._postgres_reconnect = asyncio.Lock() + if 'POSTGRES_URL' not in os.environ: LOGGER.critical('Missing POSTGRES_URL environment variable') return self.stop(loop)