From 8a18e44d9bccbe1f85d940af886edc04b9936392 Mon Sep 17 00:00:00 2001 From: schneefux Date: Thu, 9 Mar 2017 20:25:58 +0100 Subject: catch deadlocks --- api.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'api.py') diff --git a/api.py b/api.py index 873e8be..e7e690d 100644 --- a/api.py +++ b/api.py @@ -72,11 +72,13 @@ class Compiler(joblib.worker.Worker): return logging.debug("%s: compiling '%s' from '%s'", jobid, object_id, table) - tasks = [] for query in self._queries[table]: - tasks.append(asyncio.ensure_future( - self._con.execute(query, object_id))) - await asyncio.gather(*tasks) + try: + await self._con.execute(query, object_id) + except asyncpg.exceptions.DeadlockDetectedError: + logging.error("%s: deadlocked!", jobid) + raise joblib.worker.JobFailed("deadlock", + True) # critical async def startup(): -- cgit v1.3.1