Dont create objects if we do not need to

This commit is contained in:
Gavin M. Roy 2020-07-08 14:34:41 -04:00
parent 4f60c7bf0a
commit 440def6f3c

View file

@ -480,12 +480,13 @@ 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)
self._postgres_connected = asyncio.Event()
self._postgres_reconnect = asyncio.Lock()
if not await self._postgres_connect():
LOGGER.critical('PostgreSQL failed to connect, shutting down')
return self.stop(loop)