zephyr_mirror: Clear all notices from the queue before selecting.

We were having problems where we were suspiciously processing notices
at a rate of 1 notice per 15s, which suggests that we the select was
timing out even though there were notices to be fetched immediately.
We fix this by clearing the queue each time our select loop ends.

(imported from commit 7e7bfbb2126d1f4170d65d1483a0b799dcab80b9)
This commit is contained in:
Tim Abbott 2013-09-25 13:23:11 -04:00
parent a56cdac823
commit d706057ed8

View file

@ -267,17 +267,20 @@ def process_loop(log):
while True: while True:
select.select([zephyr._z.getFD()], [], [], 15) select.select([zephyr._z.getFD()], [], [], 15)
try: try:
notice = zephyr.receive(block=False) # Fetch notices from the queue until its empty
while True:
notice = zephyr.receive(block=False)
if notice is None:
break
try:
process_notice(notice, log)
except Exception:
logger.exception("Error relaying zephyr:")
time.sleep(2)
except Exception: except Exception:
logger.exception("Error checking for new zephyrs:") logger.exception("Error checking for new zephyrs:")
time.sleep(1) time.sleep(1)
continue continue
if notice is not None:
try:
process_notice(notice, log)
except Exception:
logger.exception("Error relaying zephyr:")
time.sleep(2)
if time.time() - last_check_time > 15: if time.time() - last_check_time > 15:
last_check_time = time.time() last_check_time = time.time()