def create_connection_daemon(self): connect_start_num = 0 while connect_control.keep_running: time.sleep(0.1) if not connect_control.allow_connect(): time.sleep(5) continue if self.thread_num > self.max_thread_num: continue target_conn_num = (1 - (connect_control.inactive_time()/(10*60))) * self.connection_pool_min_num if self.new_conn_pool.qsize() > target_conn_num: time.sleep(1) continue self.thread_num_lock.acquire() self.thread_num += 1 self.thread_num_lock.release() p = threading.Thread(target=self.connect_process) p.start() connect_start_num += 1 if connect_start_num > 10: time.sleep(5) connect_start_num = 0
def create_connection_daemon(self): connect_start_num = 0 while connect_control.keep_running: time.sleep(0.1) if not connect_control.allow_connect(): time.sleep(5) continue if self.thread_num > self.max_thread_num: continue target_conn_num = (1 - (connect_control.inactive_time()/(10*60))) * self.connection_pool_min_num if self.new_conn_pool.qsize() > target_conn_num: time.sleep(1) continue self.thread_num_lock.acquire() self.thread_num += 1 self.thread_num_lock.release() p = threading.Thread(target=self.connect_process) p.start() connect_start_num += 1 if connect_start_num > 10: time.sleep(5) connect_start_num = 0