Python gevent&x27;s子进程因操作错误22(EINVAL)而失败?

Python gevent&x27;s子进程因操作错误22(EINVAL)而失败?,python,gevent,Python,Gevent,将我的开发笔记本升级到Mountain Lion后,我注意到gevent.subprocess.Popen有时会失败 我有一个函数: from gevent.subprocess import check_output def do_stuff(): result = check_output(["file", "foo.py"], stderr=STDOUT) 而且它在以下回溯中失败了: Traceback (most recent call last): ... File

将我的开发笔记本升级到Mountain Lion后,我注意到
gevent.subprocess.Popen
有时会失败

我有一个函数:

from gevent.subprocess import check_output
def do_stuff():
    result = check_output(["file", "foo.py"], stderr=STDOUT)
而且它在以下回溯中失败了:

Traceback (most recent call last): ... File "myfile.py", line 105, in do_stuff result = check_output(["file", "foo.py"], stderr=STDOUT) File ".../gevent/subprocess.py", line 154, in check_output process = Popen(stdout=PIPE, *popenargs, **kwargs) File ".../gevent/subprocess.py", line 231, in __init__ errread, errwrite) File ".../gevent/subprocess.py", line 714, in _execute_child data = errpipe_read.read(1048576) File "...ython2.7/socket.py", line 380, in read data = self._sock.recv(left) File ".../gevent/fileobject.py", line 114, in recv data = os.read(self.fileno(), size) OSError: [Errno 22] Invalid argument 失败了。以上程序运行正常

发生什么事了?或者,至少,有没有任何关于如何开始调试的建议


版本:gevent 1.0b3、Python 2.7.2、OS X 10.8.2、libev 4.11(来自自制)。

查看问题,这似乎是一个已修复的已知问题。升级到1.0RC1确实解决了这个问题。

啊,这似乎解决了这个问题。谢谢你,丹尼斯。
from gevent import monkey; monkey.patch_all()

import os
import gevent
from gevent.subprocess import check_output, STDOUT

def stuff(x):
    f = x and "/dev/asdf" or "/dev/null"
    print check_output(["file", f], stderr=STDOUT).strip()

while True:
    pid = gevent.fork()
    if pid == 0:
        gevent.joinall([
            gevent.spawn(stuff, x % 2)
            for x in range(10)
        ])
    else:
        os.waitpid(-1, 0)
    gevent.sleep(1)