Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process spawn hangs forever (MacOS) #74

Closed
schlamar opened this issue Feb 21, 2013 · 5 comments
Closed

Process spawn hangs forever (MacOS) #74

schlamar opened this issue Feb 21, 2013 · 5 comments

Comments

@schlamar
Copy link
Collaborator

If I execute this simple script:

import pyuv

loop = pyuv.Loop.default_loop()
proc = pyuv.Process(loop)
proc.spawn('ls', lambda *a: None)
loop.run()

The loop.run hangs forever, it even can't be stopped with SIGINT (Ctrl+C). Happens on Python 2.7 and Python 3.3.

@schlamar
Copy link
Collaborator Author

With

for i in xrange(10):
    print (i)
    loop.run(pyuv.UV_RUN_ONCE)

it hangs at the second call to loop.run

@saghul
Copy link
Owner

saghul commented Feb 21, 2013

This is not a bug, the loop will keep looping until no active handles are left, and process handles are always active until you call close() on them.

This one works:

import pyuv

loop = pyuv.Loop.default_loop()
proc = pyuv.Process(loop)
proc.spawn('ls', lambda *a: proc.close())
loop.run()

@saghul saghul closed this as completed Feb 21, 2013
@schlamar
Copy link
Collaborator Author

@saghul
Well, in this case there is a behavior issue on Windows, because this terminates:

import pyuv

loop = pyuv.Loop.default_loop()
proc = pyuv.Process(loop)
proc.spawn('dir', lambda *a: None)
loop.run()

@saghul
Copy link
Owner

saghul commented Feb 22, 2013

I checked the code and indeed it's clear that this is handled differently. I'll report this to the libuv guys. Nevertheless, and as a rule of thumb when using pyuv, always close() handles where you are done with them. They are automatically closed if the Python object is garbage collected, but you never know when that will happen. Moreover, if you don't call close() you need to know the event loop internals to actually know when a handle is active or not, because an active handle will prevent loop.run() from returning (unless it's unref'd, but that was not this case).

@saghul
Copy link
Owner

saghul commented Feb 22, 2013

I reported this and it has already been fixed in libuv! joyent/libuv#718 I'll bump the libuv revision shortly and it will work the same on Windows and Unix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants