Пример #1
0
    def work_loop(self):
        while connect_control.keep_running and self.keep_running:
            task = self.task_queue.get(True)
            if not task:
                # None task means exit
                self.accept_task = False
                self.keep_running = False
                return
            elif task == "ping":
                if not self.head_request():
                    ip_manager.recheck_ip(self.ssl_sock.ip)
                    self.close("keep alive")
                    return
                else:
                    self.last_active_time = time.time()
                    continue

            # xlog.debug("http1 get task")
            time_now = time.time()
            if time_now - self.last_active_time > 360:
                xlog.warn("get task but inactive time:%d",
                          time_now - self.last_active_time)
                self.task = task
                self.close("inactive timeout %d" %
                           (time_now - self.last_active_time))
                return

            self.request_task(task)
            self.request_onway = False
            self.last_request_time = time_now
            self.last_active_time = time_now

            if self.processed_tasks > 35:
                self.close("lift end.")
                return
Пример #2
0
    def work_loop(self):
        while connect_control.keep_running and self.keep_running:
            task = self.task_queue.get(True)
            if not task:
                # None task means exit
                self.accept_task = False
                self.keep_running = False
                return
            elif task == "ping":
                if not self.head_request():
                    ip_manager.recheck_ip(self.ssl_sock.ip)
                    self.close("keep alive")
                    return
                else:
                    self.last_active_time = time.time()
                    continue

            # xlog.debug("http1 get task")
            time_now = time.time()
            if time_now - self.last_active_time > 360:
                xlog.warn("get task but inactive time:%d", time_now - self.last_active_time)
                self.task = task
                self.close("inactive timeout %d" % (time_now - self.last_active_time))
                return

            self.request_task(task)
            self.request_onway = False
            self.last_request_time = time_now
            self.last_active_time = time_now

            if self.processed_tasks > 35:
                self.close("lift end.")
                return