summaryrefslogtreecommitdiff
path: root/crawler.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-02-15 15:13:16 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2017-02-15 15:13:16 +0100
commit88edc2d0f25ad6c3e0335affacb8c1e92b032d2e (patch)
tree8bf8c5b1517d036b4182050cb12a95e962a07720 /crawler.py
parentca501a8dab6e931591e43157d53a95f6289b8115 (diff)
downloadapigrabber-88edc2d0f25ad6c3e0335affacb8c1e92b032d2e.tar.gz
apigrabber-88edc2d0f25ad6c3e0335affacb8c1e92b032d2e.zip
ignore server errors
Diffstat (limited to 'crawler.py')
-rw-r--r--crawler.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/crawler.py b/crawler.py
index aa0d029..f988375 100644
--- a/crawler.py
+++ b/crawler.py
@@ -1,6 +1,7 @@
#!/usr/bin/python
import asyncio
+import logging
import aiohttp
TOKEN = "aaa.bbb.ccc"
@@ -32,10 +33,14 @@ class Crawler(object):
"Accept": "application/vnd.api+json",
"Content-Encoding": "gzip"
}
- async with session.get(self._apiurl + path, headers=headers,
- params=params) as response:
- assert response.status == 200
- return await response.json()
+ try:
+ async with session.get(self._apiurl + path, headers=headers,
+ params=params) as response:
+ assert response.status == 200
+ return await response.json()
+ except aiohttp.errors.ClientResponseError:
+ logging.warning("error connecting to API, retrying")
+ return await self._req(session, path, params)
async def version(self):
"""Returns the current API version."""