summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-03-10 17:00:51 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2017-03-10 17:00:51 +0100
commit901b7bfc18d1351fc398a79b62dda93b4e247011 (patch)
treea72d25f30f2bb2cc2c52036b421c4fb565d406c6
parentd0c7a6ef3b7f04faf6ea977cf2f22bc5eb7c5f79 (diff)
downloadcompiler-901b7bfc18d1351fc398a79b62dda93b4e247011.tar.gz
compiler-901b7bfc18d1351fc398a79b62dda93b4e247011.zip
cache statements
-rw-r--r--api.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/api.py b/api.py
index 6409520..3940aad 100644
--- a/api.py
+++ b/api.py
@@ -47,10 +47,11 @@ class Compiler(joblib.worker.Worker):
# directory names: web target table
table = os.path.basename(os.path.dirname(path))
with open(path, "r", encoding="utf-8-sig") as file:
+ qry = await self._con.prepare(file.read())
try:
- self._queries[table].append(file.read())
+ self._queries[table].append(qry)
except KeyError:
- self._queries[table] = [file.read()]
+ self._queries[table] = [qry]
logging.info("loaded query '%s'", table)
@@ -74,7 +75,7 @@ class Compiler(joblib.worker.Worker):
jobid, object_id, table)
for query in self._queries[table]:
try:
- await self._con.execute(query, object_id)
+ await query.fetch(object_id)
except asyncpg.exceptions.DeadlockDetectedError:
logging.error("%s: deadlocked!", jobid)
raise joblib.worker.JobFailed("deadlock",