Non-blocking subprocess call

Nick Craig-Wood nick at craig-wood.com
Mon Jun 4 05:30:05 EDT 2007


Kevin Walzer <kw at codebykevin.com> 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.

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 <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list