def run(self): self.queue.join() # 对剩余未处理的域名进行处理 if self.cache_domains: serviceTypes = self.cache_domains # 多线程启动扫描域名 for serviceType in serviceTypes: task_update("running", 1) self.hand_domain(serviceType) task_update("running", -1) self.cache_domains = [] # 对剩余未处理的ip进行处理 if self.cache_ips: serviceTypes = self.cache_ips task_update("running", 1) self.hand_ip(serviceTypes) task_update("running", -1) self.cache_ips = [] # 最后一次提交 collector.submit() task_update("tasks", self.queue.qsize())
def run(self): while 1: # 对剩余未处理的域名进行处理 if self.cache_domains: self.lock.acquire() service_types = self.cache_domains self.cache_domains = [] self.lock.release() for serviceType in service_types: task_update("running", 1) try: self.hand_domain(serviceType) except Exception as e: logger.error(repr(sys.exc_info())) pass task_update("running", -1) # 对剩余未处理的ip进行处理 if self.cache_ips: self.lock.acquire() service_types = self.cache_ips self.cache_ips = [] self.lock.release() task_update("running", 1) try: self.hand_ip(service_types) except Exception as e: logger.error(repr(sys.exc_info())) pass task_update("runnning", -1) # 最后一次提交 collector.submit() task_update("tasks", self.queue.qsize() + self.ip_queue.qsize()) time.sleep(random.randint(2, 10))