use "while true" in gevent(Greenlets), the program will stop gradually

535 views Asked by At

I want to use the greenlets as the thread:

  def check_all_proxy():
        while True:
            try:
                r = get_redis()
                proxy = r.spop(tmp_key)
                if proxy == None:
                    gevent.sleep(3)
                    continue
                if_right, used_time = check_proxy(proxy, TEST_URL)
                if if_right:
                    r.sadd(key, proxy)
                else:
                    r.setex(proxy, 1, 120)
                gevent.sleep(0) 
            except:
                gevent.sleep(2)

   gevent.joinall([gevent.spawn(check_all_proxy) for i in xrange(200)])

But it will stop gradually. What is the reason?

Thanks

0

There are 0 answers