def verify_proxy_useful(): """ 定时任务, 验证 useful 中的代理是否可用 :return: """ logger.info('开始验证 useful 代理') count = ProxyPool.count() if count == 0: logger.info('useful 代理数量为零, 验证 done') return with futures.ThreadPoolExecutor(max_workers=10) as executor: proxys = ProxyPool.all() for proxy, result in zip(proxys, executor.map(_verify_proxy_useful, proxys)): # 无需知道结果 pass logger.info('验证 useful 代理 done')
def count(): n = ProxyPool.count() return str(n)