Re: polling for output from a subprocess module
- From: Thomas Bellman <bellman@xxxxxxxxxxxxxx>
- Date: Wed, 6 Feb 2008 07:18:35 +0000 (UTC)
Ivo <noreply@xxxxxxxxx> wrote:
Thomas Bellman wrote:
However, the os.read() function will only read what is currentlybe carefull that you specify how much you want to read at a time,
available. Note, though, that os.read() does not do line-based
I/O, so depending on the timing you can get incomplete lines, or
multiple lines in one read.
otherwise it cat be that you keep on reading.
Specify read(1024) or somesuch.
Well, of course you need to specify how much you want to read.
Otherwise os.read() throws an exception:
>>> import sys, os
>>> os.read(sys.stdin.fileno())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: read() takes exactly 2 arguments (1 given)
In case of my PPCEncoder I recompiled the mencoder subprocess to deliver
me lines that end with \n.
If anyone can tell me how to read a continues stream than I am really
interested.
I have never had any problem when using the os.read() function,
as long as I understand the effects of output buffering in the
subprocess. The file.read() method is a quite different animal.
(And then there's the problem of getting mplayer/mencoder to
output any *useful* information, but that is out of the scope of
this newsgroup. :-)
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"God is real, but Jesus is an integer." ! bellman @ lysator.liu.se
! Make Love -- Nicht Wahr!
.
- References:
- polling for output from a subprocess module
- From: jakub . hrozek
- Re: polling for output from a subprocess module
- From: Thomas Bellman
- Re: polling for output from a subprocess module
- From: Ivo
- polling for output from a subprocess module
- Prev by Date: Re: boolean decisions
- Next by Date: Re: Using a class as a structure/container
- Previous by thread: Re: polling for output from a subprocess module
- Next by thread: Too many open files
- Index(es):
Relevant Pages
|