Mercurial > templog
comparison py/configwaiter.py @ 265:78c542f03030
Limit log
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 13 Jun 2015 22:49:14 +0800 |
parents | 654caee52c83 |
children |
comparison
equal
deleted
inserted
replaced
264:205809a8872f | 265:78c542f03030 |
---|---|
1 import asyncio | 1 import asyncio |
2 import datetime | |
3 | |
2 import aiohttp | 4 import aiohttp |
3 | 5 |
4 import utils | 6 import utils |
5 from utils import L,D,EX,W,E | 7 from utils import L,D,EX,W,E |
6 import config | 8 import config |
10 | 12 |
11 def __init__(self, server): | 13 def __init__(self, server): |
12 self.server = server | 14 self.server = server |
13 self.epoch_tag = None | 15 self.epoch_tag = None |
14 self.http_session = aiohttp.ClientSession() | 16 self.http_session = aiohttp.ClientSession() |
17 self.limitlog = utils.NotTooOften(datetime.timedelta(minutes=15)) | |
15 | 18 |
16 @asyncio.coroutine | 19 @asyncio.coroutine |
17 def run(self): | 20 def run(self): |
18 # wait until someting has been uploaded (the uploader itself waits 5 seconds) | 21 # wait until someting has been uploaded (the uploader itself waits 5 seconds) |
19 yield from asyncio.sleep(10) | 22 yield from asyncio.sleep(10) |
47 self.server.reload_signal(True) | 50 self.server.reload_signal(True) |
48 elif r.status == 304: | 51 elif r.status == 304: |
49 pass | 52 pass |
50 else: | 53 else: |
51 # longer timeout to avoid spinning | 54 # longer timeout to avoid spinning |
55 text = yield from asyncio.wait_for(r.text(), 600) | |
56 D("Bad server response. %d %s" % (r.status, text)) | |
52 yield from asyncio.sleep(30) | 57 yield from asyncio.sleep(30) |
53 | 58 |
54 except asyncio.TimeoutError: | 59 except aiohttp.errors.ClientError as e: |
55 D("configwaiter http timed out") | 60 self.limitlog.log("Error with configwaiter: %s" % str(e)) |
56 pass | 61 except asyncio.TimeoutError as e: |
62 self.limitlog.log("configwaiter http timed out: %s" % str(e)) | |
57 except Exception as e: | 63 except Exception as e: |
58 EX("Error watching config: %s" % str(e)) | 64 EX("Error watching config: %s" % str(e)) |
59 | |
60 | |
61 | |
62 |