Non-blocking subprocess call

K

Kevin Walzer

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

Josiah Carlson

Kevin said:
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/Cookbook/Python/Recipe/440554

- Josiah
 
N

Nick Craig-Wood

Kevin Walzer said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,196
Latest member
ScottChare

Latest Threads

Top