Calling subprocess with arguments

Mike Kazantsev mk.fraggod at gmail.com
Fri Jun 19 11:21:42 EDT 2009


On Fri, 19 Jun 2009 08:07:29 -0700
Tyler Laing <trinioler at gmail.com> wrote:

> I can't use communicate, as it waits for the child process to terminate.
> Basically it blocks. I'm trying to have dynamic communication between the
> python program, and vlc.

Unfortunately, subprocess module doesn't allow it out-of-the-box, but
you can use fnctl calls to perform non-blocking reads/writes on it's
pipes, like this:

  flags = fcntl.fcntl(fd, fcntl.F_GETFL)
  fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)

After that, you can grab all the available data from the pipe at any
given time w/o blocking.

Try this recipe:

  http://code.activestate.com/recipes/576759/

-- 
Mike Kazantsev // fraggod.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 205 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090619/9bea055c/attachment-0001.sig>


More information about the Python-list mailing list