0

After upgrading my development laptop to Mountain Lion, I've noticed that gevent.subprocess.Popen fails… Sometimes.

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).

Charles
  • 50,943
  • 13
  • 104
  • 142
David Wolever
  • 148,955
  • 89
  • 346
  • 502

1 Answers1

0

Looking into the 1.0RC1 change log it seems like this was a known issue that was fixed. Upgrading to 1.0RC1 does fix it.

David Wolever
  • 148,955
  • 89
  • 346
  • 502