protocol.py 文件源码

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

项目:privcount 作者: privcount 项目源码 文件源码
def handle_checkin_event(self, event_type, event_payload):
        if event_type == "CHECKIN":
            parts = event_payload.split()
            if len(parts) == 1:
                period = int(parts[0])
                # we have to store the checkin task in the factory,
                # because the protocol is re-created on every connection
                checkin_task = self.factory.get_checkin_task()
                if checkin_task is not None and checkin_task.running:
                    checkin_task.stop()
                    self.factory.set_checkin_task(None)
                checkin_task = task.LoopingCall(self.factory.do_checkin)
                self.factory.set_checkin_task(checkin_task)
                # we ignore any errors from do_checkin, see bug #47
                checkin_deferred = checkin_task.start(period, now=False)
                checkin_deferred.addErrback(errorCallback)
                self.sendLine("CHECKIN SUCCESS")
                self.protocol_succeeded()
                return True
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号