简体   繁体   English

gevent的子进程因OSError 22(EINVAL)而失败?

[英]gevent's subprocess fails with OSError 22 (EINVAL)?

After upgrading my development laptop to Mountain Lion, I've noticed that gevent.subprocess.Popen fails… Sometimes. 将我的开发笔记本电脑升级到Mountain Lion之后,我注意到gevent.subprocess.Popen失败了……有时。

I've got a function: 我有一个功能:

from gevent.subprocess import check_output
def do_stuff():
    result = check_output(["file", "foo.py"], stderr=STDOUT)

And it is failing with the traceback below: 并且它的以下追溯失败:

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

However, my attempt to recreate the bug: 但是,我尝试重新创建该错误:

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)

Has failed. 失败了。 The above programs runs without issue. 以上程序运行没有问题。

What's going on? 这是怎么回事? Or, at very least, any pointers on how I could start debugging this? 或者,至少,关于如何开始调试它的任何指示?

Versions: gevent 1.0b3, Python 2.7.2, OS X 10.8.2, libev 4.11 (from homebrew). 版本:gevent 1.0b3,Python 2.7.2,OS X 10.8.2,libev 4.11(来自自制软件)。

Looking into the 1.0RC1 change log it seems like this was a known issue that was fixed. 查看1.0RC1更改日志 ,似乎这是已解决的已知问题。 Upgrading to 1.0RC1 does fix it. 升级到1.0RC1确实可以修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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