diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-03-04 11:11:19 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-03-04 11:11:19 +0100 |
| commit | 8d58a4f5f754b6541af84478a2df3fba70db94be (patch) | |
| tree | a992eea6271737aaf88239facf026f5d1688e8bc | |
| parent | 04e821ad0fb4e015dbbf85e3a34aaf4be13d55b4 (diff) | |
| download | joblib-0.4.0.tar.gz joblib-0.4.0.zip | |
wait for db to start up0.4.0
| -rw-r--r-- | joblib.py | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -3,6 +3,7 @@ import asyncio import asyncpg import json +import logging class JobQueue(object): @@ -11,7 +12,19 @@ class JobQueue(object): async def connect(self, **args): """Connect the database.""" - self._pool = await asyncpg.create_pool(**args) + logging.info("connecting to queue database") + while True: + try: + self._pool = await asyncpg.create_pool(**args) + break + except asyncpg.exceptions.CannotConnectNowError: + logging.warning( + "queue database is not ready yet, retrying") + await asyncio.sleep(1) + except asyncpg.exceptions.TooManyConnectionsError: + logging.warning( + "queue database has too many clients, retrying") + await asyncio.sleep(1) async def setup(self): """Initialize the database.""" |
