Getting stdout from other processes
Miki
miki.tebeka at gmail.com
Fri Feb 22 12:56:28 EST 2008
Hello Matthias,
> as I found out, it is possible to get the output of other programs
> using os.popen() and read from it. However this method is blocking for
> server processes and programs that don't stop immediately. Has anyone
> an idea how to get the output of such programs?
The current "official" module to use is subprocess (pipe =
Popen([client], stdout=PIPE))
However if the client is sending data, reading from the pipe.stdout
will block the server.
If you *need* to wait, then you can use pipe.wait(), otherwise do as
Diez suggested and have a thread
read the client output and propagate it to the main loop (maybe using
Queue.Queue)
HTH,
--
Miki <miki.tebeka at gmail.com>
http://pythonwise.blogspot.com
More information about the Python-list
mailing list