zephyr_mirror_backend.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:python-zulip-api 作者: zulip 项目源码 文件源码
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:")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号