468,458 Members | 1,825 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,458 developers. It's quick & easy.

Non-blocking subprocess call

I'm currently using os.popen in an application of mine, which calls for
non-blocking data, in this fashion:

self.file = os.popen('echo %s | sudo -S /sw/bin/fink -y install %s' %
(self.passtext, self.packagename), 'r', os.O_NONBLOCK)

What is the equivalent/comparable call in the new subprocess module? I
can't find any reference in the Python docs to non-blocking streams.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Jun 2 '07 #1
3 2200
Kevin Walzer wrote:
I'm currently using os.popen in an application of mine, which calls for
non-blocking data, in this fashion:

self.file = os.popen('echo %s | sudo -S /sw/bin/fink -y install %s' %
(self.passtext, self.packagename), 'r', os.O_NONBLOCK)

What is the equivalent/comparable call in the new subprocess module? I
can't find any reference in the Python docs to non-blocking streams.
If you are talking about non-blocking reading and writing from the
subprocess, there isn't natively. But there is a cookbook entry:
http://aspn.activestate.com/ASPN/Coo.../Recipe/440554

- Josiah
Jun 2 '07 #2
Josiah Carlson wrote:
>
If you are talking about non-blocking reading and writing from the
subprocess, there isn't natively. But there is a cookbook entry:
http://aspn.activestate.com/ASPN/Coo.../Recipe/440554

- Josiah
Any idea why this feature was removed from the language? It seems pretty
essential to me.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Jun 2 '07 #3
Kevin Walzer <kw@codebykevin.comwrote:
I'm currently using os.popen in an application of mine, which calls for
non-blocking data, in this fashion:

self.file = os.popen('echo %s | sudo -S /sw/bin/fink -y install %s' %
(self.passtext, self.packagename), 'r', os.O_NONBLOCK)

What is the equivalent/comparable call in the new subprocess module? I
can't find any reference in the Python docs to non-blocking
streams.
You'll probably be better off with the pexpect module for this

http://pexpect.sourceforge.net/

Doesn't work on windows. Looks like you are doing OS X though so
should work fine there

--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Jun 4 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by lothar | last post: by
4 posts views Thread by bwmiller16 | last post: by
32 posts views Thread by Adrian Herscu | last post: by
14 posts views Thread by Patrick Kowalzick | last post: by
399 posts views Thread by =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.