예제 #1
0
파일: scheduler.py 프로젝트: xuqisong/IP-
 def test_proxies(cycle=VALID_CHECK_CYCLE):
     """
     检查代理队列左半边(旧的)队列的代理有效性,无效的剔除,有效的重新放入队列右侧
     :param cycle: 检测周期
     """
     conn = RedisClient()
     tester = ValidityTester()
     while True:
         print('testing & refreshing ips...')
         count = int(0.5 * conn.list_len)
         if count == 0:
             print('0 ip, waiting for adding...')
             time.sleep(cycle)
             continue
         raw_proxies = conn.get_for_test(count)  #从数据库中获取ip进行测试
         tester.set_raw_proxies(raw_proxies)
         tester.test()
         time.sleep(cycle)