summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-02-26 18:35:32 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2017-02-26 18:35:32 +0100
commit90ee943705e6ed373b778929c0bab94c6e34f674 (patch)
tree533a3ed26fec69e07fa945617d5d0aae33047b99
parentf54bb387475cd19e2f8d32cca131e2abb5eea8fd (diff)
downloadapigrabber-90ee943705e6ed373b778929c0bab94c6e34f674.tar.gz
apigrabber-90ee943705e6ed373b778929c0bab94c6e34f674.zip
report job fails in queue
-rw-r--r--api.py8
-rw-r--r--crawler.py5
m---------joblib0
3 files changed, 10 insertions, 3 deletions
diff --git a/api.py b/api.py
index 2dfa964..1da9e8d 100644
--- a/api.py
+++ b/api.py
@@ -69,8 +69,12 @@ class Worker(object):
if jobid is None:
raise LookupError("no jobs available")
logging.debug("%s: starting job", jobid)
- await self._execute_job(jobid, payload, priority)
- await self._queue.finish(jobid)
+ try:
+ await self._execute_job(jobid, payload, priority)
+ await self._queue.finish(jobid)
+ except crawler.ApiError as error:
+ logging.warning("%s: failed", jobid)
+ await self._queue.fail(jobid, error.args[0])
logging.debug("%s: finished job", jobid)
async def run(self):
diff --git a/crawler.py b/crawler.py
index def9f82..44396ae 100644
--- a/crawler.py
+++ b/crawler.py
@@ -7,6 +7,9 @@ import aiohttp
APIURL = "https://api.dc01.gamelockerapp.com/"
+class ApiError(Exception):
+ pass
+
class Crawler(object):
def __init__(self, token):
"""Sets constants."""
@@ -65,7 +68,7 @@ class Crawler(object):
if "errors" in res:
logging.warn("API returned error: '%s'",
res["errors"])
- break
+ raise ApiError(res["errors"])
yield res
diff --git a/joblib b/joblib
-Subproject f7b858a53e0b3233e04186d18d309f8403ea99d
+Subproject 31d0588a35c8df17a5d3adcfc25af2b72c896cc