diff py/configwaiter.py @ 294:6bacd8ca9f8f

merge
author Matt Johnston <matt@ucc.asn.au>
date Sat, 06 Jul 2019 18:30:25 +0800
parents 78c542f03030
children
line wrap: on
line diff
--- a/py/configwaiter.py	Sat Jul 06 18:29:45 2019 +0800
+++ b/py/configwaiter.py	Sat Jul 06 18:30:25 2019 +0800
@@ -1,4 +1,6 @@
 import asyncio
+import datetime
+
 import aiohttp
 
 import utils
@@ -12,6 +14,7 @@
         self.server = server
         self.epoch_tag = None
         self.http_session = aiohttp.ClientSession()
+        self.limitlog = utils.NotTooOften(datetime.timedelta(minutes=15))
 
     @asyncio.coroutine
     def run(self):
@@ -49,14 +52,13 @@
                 pass
             else:
                 # longer timeout to avoid spinning
+                text = yield from asyncio.wait_for(r.text(), 600)
+                D("Bad server response. %d %s" % (r.status, text))
                 yield from asyncio.sleep(30)
 
-        except asyncio.TimeoutError:
-            D("configwaiter http timed out")
-            pass
+        except aiohttp.errors.ClientError as e:
+            self.limitlog.log("Error with configwaiter: %s" % str(e))
+        except asyncio.TimeoutError as e:
+            self.limitlog.log("configwaiter http timed out: %s" % str(e))
         except Exception as e:
             EX("Error watching config: %s" % str(e))
-
-
-
-