non-blocking PIPE read on Windows

Simon Forman rogue_pedro at yahoo.com
Fri Jul 28 03:15:47 EDT 2006


placid wrote:
> Hi all,
>
> I have been looking into non-blocking read (readline) operations on
> PIPES on windows XP and there seems to be no way of doing this. Ive
> read that you could use a Thread to read from the pipe, but if you
> still use readline() wouldnt the Thread block too?

Yes it will, but that's ok.  In this case that's what it's for.  While
the thread waits for the readline(), the rest of your program continues
to carry on.

>
> What i need to do is, create a process using subprocess.Popen, where
> the subprocess outputs information on one line (but the info
> continuesly changes and its always on the same line) and read this
> information without blocking, so i can retrieve other data from the
> line i read in then put this in a GUI interface.
>
>
> readline() blocks until the newline character is read, but when i use
> read(X) where X is a number of bytes then it doesnt block(expected
> functionality) but i dont know how many bytes the line will be and its
> not constant so i cant use this too.
> 
> Any ideas of solving this problem?
> 
> 
> Cheers




More information about the Python-list mailing list