summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-03-04 11:11:19 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2017-03-04 11:11:19 +0100
commit8d58a4f5f754b6541af84478a2df3fba70db94be (patch)
treea992eea6271737aaf88239facf026f5d1688e8bc
parent04e821ad0fb4e015dbbf85e3a34aaf4be13d55b4 (diff)
downloadjoblib-0.4.0.tar.gz
joblib-0.4.0.zip
wait for db to start up0.4.0
-rw-r--r--joblib.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/joblib.py b/joblib.py
index de69cfd..7ecde6a 100644
--- a/joblib.py
+++ b/joblib.py
@@ -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."""