gevent queue如何阻塞和empy队列直到项目进入队列?

2024-06-17 11:31:36 发布

您现在位置:Python中文网/ 问答频道 /正文

Gevent不工作。我认为下面的代码会永远阻塞,但我得到了下面的错误。在

from gevent import monkey; monkey.patch_all()
import gevent
import gevent.queue    
queue = gevent.queue.Queue()
queue.get(block=True, timeout=None)



File "/home/ubuntu/workspace/zenserver/upload_pusher.py", line 53, in proccess_file
    filepath = queue.get(block=True, timeout=None)
  File "/usr/local/lib/python2.7/dist-packages/gevent-1.0b2-py2.7-linux-x86_64.egg/gevent/queue.py", line 189, in get
    result = waiter.get()
  File "/usr/local/lib/python2.7/dist-packages/gevent-1.0b2-py2.7-linux-x86_64.egg/gevent/hub.py", line 616, in get
    return self.hub.switch()
  File "/usr/local/lib/python2.7/dist-packages/gevent-1.0b2-py2.7-linux-x86_64.egg/gevent/hub.py", line 373, in switch
    return greenlet.switch(self)
gevent.hub.LoopExit: This operation would block forever

Tags: inpyimportgetqueuelibpackagesusr
1条回答
网友
1楼 · 发布于 2024-06-17 11:31:36

你得到了这个例外,因为没有其他的绿色食品可供选择。你已经要求一个也是唯一的一个小绿叶(主要的绿叶)阻止,但是它不可能醒来(因为没有其他的小绿叶)。基本上这是gevent让你知道死锁。在

相关问题 更多 >