event.py 文件源码

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

项目:ransomcare 作者: Happyholic1203 项目源码 文件源码
def _event_loop(self):
        cls = type(self)
        while self._is_active:
            try:
                evt = cls.events.get(block=False)
            except eventlet.queue.Empty:
                eventlet.sleep(self._loop_period)
                continue
            except Exception as e:
                logger.exception(e)
                continue
            if evt == self._evt_stop:
                continue
            evt_cls = type(evt)
            # locate the handler method
            handlers = cls.handlers.get(evt_cls)
            if not handlers:
                raise Exception('%s did not register event: %s' %
                                (cls.__name__, evt_cls.__name__))
            # invoke the handler method
            for handler in handlers:
                handler(evt)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号