简体   繁体   中英

Gevent hub raises exception on pool

Running gevent pool gives me the following exception on join :

return greenlet.switch(self)

gevent.hub.LoopExit: ('This operation would block forever', Hub at 0x105cbd190 select default pending=0 ref=0)

Code is:

    queue = gevent.queue.Queue(items=range(5))
    pool = gevent.pool.Pool(3)
    pool.map(self.foo_index, queue)
    pool.join(raise_error=True)

The error seems to occur before join is called during map . Oh no wait, an exception is raised immediately which must come from join : this is confusing.

Using map_async on your sample code did resolved the issue on my side. I hope this is what you are looking for.

The error is raised because of the gevent.queue.Queue object. I replaced it with a default list and now it works. Not sure why the Queue is a problem, as it seems to be an iterable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM