sync-inoreader: requests should timeout
authorJack Miller <jack@codezen.org>
Mon, 29 Jun 2015 21:04:35 +0000 (16:04 -0500)
committerJack Miller <jack@codezen.org>
Mon, 29 Jun 2015 21:07:50 +0000 (16:07 -0500)
Apparently the standard socket timeout is ignored? Regardless,
occasionally the request seems to hang for a long period (possibly
server trouble?) and it appears to deadlock the daemon because the
feed's internal lock is being held, which halts sync operations.

plugins/sync-inoreader.py

index 3003988..5508e7a 100644 (file)
@@ -94,7 +94,7 @@ class CantoInoreaderAPI():
         headers['Passwd'] = PASSWORD
 
         try:
-            r = requests.get("https://www.inoreader.com/accounts/ClientLogin", headers)
+            r = requests.get("https://www.inoreader.com/accounts/ClientLogin", headers, timeout=1)
         except Exception as e:
             raise InoreaderReqFailed(str(e))
 
@@ -128,7 +128,10 @@ class CantoInoreaderAPI():
             headers = self.extra_headers.copy()
             headers["Authorization"] = "GoogleLogin auth=" + self.authorization
 
-            r = requests.get(BASE_URL + path, params=query, headers=headers)
+            try:
+                r = requests.get(BASE_URL + path, params=query, headers=headers, timeout=1)
+            except requests.exceptions.Timeout:
+                raise InoreaderReqFailed
 
             if r.status_code != 200:
                 log.debug("STATUS %s", r.status_code)