def process_loop(log):
# type: (IO[Any]) -> None
restart_check_count = 0
last_check_time = time.time()
while True:
select.select([zephyr._z.getFD()], [], [], 15)
try:
# 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:
logger.exception("Error checking for new zephyrs:")
time.sleep(1)
continue
if time.time() - last_check_time > 15:
last_check_time = time.time()
try:
maybe_restart_mirroring_script()
if restart_check_count > 0:
logger.info("Stopped getting errors checking whether restart is required.")
restart_check_count = 0
except Exception:
if restart_check_count < 5:
logger.exception("Error checking whether restart is required:")
restart_check_count += 1
if options.forward_class_messages:
try:
update_subscriptions()
except Exception:
logger.exception("Error updating subscriptions from Zulip:")
评论列表
文章目录