From 6186dbc0e46df0d4e55f2f8bb179489ae00bfe41 Mon Sep 17 00:00:00 2001 From: Vainsocial root Date: Sun, 12 Mar 2017 10:18:44 +0000 Subject: hotfix: do not retry forever --- crawler.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crawler.py') diff --git a/crawler.py b/crawler.py index ccc4a73..a341c71 100644 --- a/crawler.py +++ b/crawler.py @@ -36,6 +36,7 @@ class Crawler(object): "Accept": "application/vnd.api+json", "Accept-Encoding": "gzip" } + retries = 5 while True: try: async with session.get(self._apiurl + path, headers=headers, @@ -57,6 +58,11 @@ class Crawler(object): json.decoder.JSONDecodeError) as err: # API bug? logging.error("API error '%s', retrying", err) + retries -= 1 + if retries == 0: + logging.error("Giving up") + raise ApiError(err) + await asyncio.sleep(5) async def matches(self, params, region="na"): -- cgit v1.3.1