def report_connect_fail(self, ip, force_remove=False): self.ip_lock.acquire() try: time_now = time.time() if not ip in self.ip_dict: xlog.debug("report_connect_fail %s not exist", ip) return if force_remove: if self.ip_dict[ip]['fail_times'] == 0: self.good_ip_num -= 1 self.bad_ip_num += 1 del self.ip_dict[ip] if ip in self.gws_ip_list: self.gws_ip_list.remove(ip) xlog.info("remove ip:%s left amount:%d gws_num:%d", ip, len(self.ip_dict), len(self.gws_ip_list)) return self.ip_dict[ip]['links'] -= 1 # ignore if system network is disconnected. if check_local_network.network_stat == "Fail": xlog.debug("report_connect_fail network fail") return check_local_network.continue_fail_count += 1 if check_local_network.continue_fail_count > 10: check_local_network.network_stat = "unknown" xlog.debug("report_connect_fail continue_fail_count:%d", check_local_network.continue_fail_count) check_local_network.triger_check_network() return fail_time = self.ip_dict[ip]["fail_time"] if time_now - fail_time < 1: xlog.debug("fail time too near %s", ip) return if self.ip_dict[ip]['fail_times'] == 0: self.good_ip_num -= 1 self.bad_ip_num += 1 self.ip_dict[ip]['fail_times'] += 1 self.append_ip_history(ip, "fail") self.ip_dict[ip]["fail_time"] = time_now check_local_network.triger_check_network() self.to_check_ip_queue.put((ip, time_now + 10)) xlog.debug("report_connect_fail:%s", ip) except Exception as e: xlog.exception("report_connect_fail err:%s", e) finally: self.iplist_need_save = True self.ip_lock.release() if not self.is_ip_enough(): self.search_more_google_ip()