Python eventlet在使用futures.ProcessPoolExecutor时挂起

Python eventlet在使用futures.ProcessPoolExecutor时挂起,python,python-2.7,monkeypatching,eventlet,concurrent.futures,Python,Python 2.7,Monkeypatching,Eventlet,Concurrent.futures,我使用的是Ubuntu 12.04服务器x64、Python 2.7.3、futures==2.1.5、eventlet==0.14.0 有人遇到过同样的问题吗 import eventlet import futures import random # eventlet.monkey_patch() # Uncomment this line and it will hang! def test(): if random.choice((True, False)):

我使用的是Ubuntu 12.04服务器x64、Python 2.7.3、futures==2.1.5、eventlet==0.14.0

有人遇到过同样的问题吗

import eventlet
import futures
import random

# eventlet.monkey_patch() # Uncomment this line and it will hang!

def test():
    if random.choice((True, False)):
        raise Exception()
    print "OK this time"

def done(f):
    print "done callback!"

def main():
    with futures.ProcessPoolExecutor() as executor:
        fu = []
        for i in xrange(6):
            f = executor.submit(test)
            f.add_done_callback(done)
            fu.append(f)
        futures.wait(fu, return_when=futures.ALL_COMPLETED)

if __name__ == '__main__':
    main()
如果取消对该行的注释,此代码将挂起。我只能通过按Ctrl+C来停止。在这种情况下,将打印以下键盘中断回溯:

这在ThreadPoolExecutor中可以正常工作


任何反馈都是值得赞赏的

我认为这个键盘中断到达了启动进程,因为在ubuntu和大多数linux系统下,新进程是用fork创建的-从当前进程开始,使用相同的stdin和stdout以及stderr。因此键盘中断可以到达子进程。也许知道更多的人可以添加想法。

我通过为猴子补丁设置os=True成功地解决了这个问题。然而,这种行为的本质还不清楚,需要进一步研究。没错,这确实有帮助。但目前我无法改变项目的补丁策略。另外,我认为默认情况下它们都是真的..不管怎样,如果指定os=True,其他任何东西都不会得到修补。:)我试着不补线,结果成功了。线程肯定应该被修补,我认为这是我们使用eventlet的唯一原因:)eventlet被设计用来解决在回调中编写代码的问题。eventlet+期货/回调有什么好处?感谢您的参与。我想我的问题不是很清楚,对不起。我把它更新得更明显了