Example #1
0
    def keep_alive_thread(self):
        while connect_control.keep_running:
            if not connect_control.is_active():
                time.sleep(1)
                continue

            to_keep_live_list = self.new_conn_pool.get_need_keep_alive(maxtime=self.keep_alive-3)

            for ssl_sock in to_keep_live_list:
                inactive_time = time.time() - ssl_sock.last_use_time
                if inactive_time > self.keep_alive or not self.ssl_timeout_cb:
                    google_ip.report_connect_closed(ssl_sock.ip, "alive_timeout")
                    ssl_sock.close()
                else:
                    # put ssl to worker
                    try:
                        self.ssl_timeout_cb(ssl_sock)
                    except:
                        # no appid avaiable
                        pass

            for host in self.host_conn_pool:
                host_list = self.host_conn_pool[host].get_need_keep_alive(maxtime=self.keep_alive-3)

                for ssl_sock in host_list:
                    google_ip.report_connect_closed(ssl_sock.ip, "host pool alive_timeout")
                    ssl_sock.close()

            time.sleep(1)
Example #2
0
    def keep_alive_thread(self):
        while connect_control.keep_running:
            if not connect_control.is_active():
                time.sleep(1)
                continue

            to_keep_live_list = self.new_conn_pool.get_need_keep_alive(
                maxtime=self.keep_alive - 3)

            for ssl_sock in to_keep_live_list:
                inactive_time = time.time() - ssl_sock.last_use_time
                if inactive_time > self.keep_alive or not self.ssl_timeout_cb:
                    google_ip.report_connect_closed(ssl_sock.ip,
                                                    "alive_timeout")
                    ssl_sock.close()
                else:
                    # put ssl to worker
                    try:
                        self.ssl_timeout_cb(ssl_sock)
                    except:
                        # no appid avaiable
                        pass

            for host in self.host_conn_pool:
                host_list = self.host_conn_pool[host].get_need_keep_alive(
                    maxtime=self.keep_alive - 3)

                for ssl_sock in host_list:
                    google_ip.report_connect_closed(ssl_sock.ip,
                                                    "host pool alive_timeout")
                    ssl_sock.close()

            time.sleep(1)
Example #3
0
    def keep_alive_thread(self):
        while self.keep_alive and connect_control.keep_running:
            if not connect_control.is_active():
                time.sleep(1)
                continue

            new_list = self.new_conn_pool.get_need_keep_alive(maxtime=self.keep_alive-3)
            old_list = self.gae_conn_pool.get_need_keep_alive(maxtime=self.keep_alive-3)
            to_keep_live_list = new_list + old_list

            for ssl_sock in to_keep_live_list:
                inactive_time = time.time() - ssl_sock.last_use_time
                if inactive_time > self.keep_alive:
                    google_ip.report_connect_closed(ssl_sock.ip, "alive_timeout")
                    ssl_sock.close()
                else:
                    self.start_keep_alive(ssl_sock)

            for host in self.host_conn_pool:
                host_list = self.host_conn_pool[host].get_need_keep_alive(maxtime=self.keep_alive-3)

                for ssl_sock in host_list:
                    google_ip.report_connect_closed(ssl_sock.ip, "host pool alive_timeout")
                    ssl_sock.close()
            #self.create_more_connection()

            time.sleep(1)
Example #4
0
    def keep_alive_thread(self):
        while self.keep_alive and connect_control.keep_running:
            if not connect_control.is_active():
                time.sleep(1)
                continue

            new_list = self.new_conn_pool.get_need_keep_alive(
                maxtime=self.keep_alive - 3)
            old_list = self.gae_conn_pool.get_need_keep_alive(
                maxtime=self.keep_alive - 3)
            to_keep_live_list = new_list + old_list

            for ssl_sock in to_keep_live_list:
                inactive_time = time.time() - ssl_sock.last_use_time
                if inactive_time > self.keep_alive:
                    ssl_sock.close()
                    continue

                if self.new_conn_pool.qsize() + self.gae_conn_pool.qsize(
                ) < self.connection_pool_max_num:
                    self.start_keep_alive(ssl_sock)
                else:
                    ssl_sock.close()

            if self.new_conn_pool.qsize() < self.connection_pool_min_num:
                self.create_more_connection()

            time.sleep(1)
Example #5
0
    def keep_alive_thread(self):
        while self.keep_alive and connect_control.keep_running:
            if not connect_control.is_active():
                time.sleep(1)
                continue

            new_list = self.new_conn_pool.get_need_keep_alive(maxtime=self.keep_alive-3)
            old_list = self.gae_conn_pool.get_need_keep_alive(maxtime=self.keep_alive-3)
            to_keep_live_list = new_list + old_list

            for ssl_sock in to_keep_live_list:
                inactive_time = time.time() - ssl_sock.last_use_time
                if inactive_time > self.keep_alive:
                    google_ip.report_connect_closed(ssl_sock.ip, "alive_timeout")
                    ssl_sock.close()
                else:
                    self.start_keep_alive(ssl_sock)

            for host in self.host_conn_pool:
                host_list = self.host_conn_pool[host].get_need_keep_alive(maxtime=self.keep_alive-3)

                for ssl_sock in host_list:
                    google_ip.report_connect_closed(ssl_sock.ip, "host pool alive_timeout")
                    ssl_sock.close()
            #self.create_more_connection()

            time.sleep(1)
Example #6
0
    def keep_alive_thread(self):
        while self.keep_alive and connect_control.keep_running:
            if not connect_control.is_active():
                time.sleep(1)
                continue

            new_list = self.new_conn_pool.get_need_keep_alive(maxtime=self.keep_alive-3)
            old_list = self.gae_conn_pool.get_need_keep_alive(maxtime=self.keep_alive-3)
            to_keep_live_list = new_list + old_list

            for ssl_sock in to_keep_live_list:
                inactive_time = time.time() - ssl_sock.last_use_time
                if inactive_time > self.keep_alive:
                    ssl_sock.close()
                    continue

                if self.new_conn_pool.qsize() + self.gae_conn_pool.qsize() < self.connection_pool_max_num:
                    self.start_keep_alive(ssl_sock)
                else:
                    ssl_sock.close()

            if self.new_conn_pool.qsize() < self.connection_pool_min_num:
                self.create_more_connection()

            time.sleep(1)
Example #7
0
    def keep_alive_thread(self):
        while connect_control.keep_running:
            if not connect_control.is_active():
                time.sleep(1)
                continue

            to_keep_live_list = self.new_conn_pool.get_need_keep_alive(maxtime=self.ssl_first_use_timeout-2)

            for ssl_sock in to_keep_live_list:
                inactive_time = time.time() - ssl_sock.last_use_time
                if inactive_time > self.ssl_first_use_timeout + 5 or not self.ssl_timeout_cb:
                    ip_manager.report_connect_closed(ssl_sock.ip, "alive_timeout")
                    ssl_sock.close()
                else:
                    # put ssl to worker
                    try:
                        self.ssl_timeout_cb(ssl_sock)
                    except:
                        # no appid avaiable
                        pass

            time.sleep(1)