将我的开发笔记本电脑升级到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
但是,我尝试重新创建错误:
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)
失败了。上述程序没有问题。
发生了什么事?或者,至少,关于我如何开始调试它的任何指针?
版本:gevent 1.0b3,Python 2.7.2,OS X 10.8.2,libev 4.11(来自自制软件)。