read and readline hanging

Olivier Lefevre lefevrol at yahoo.com
Sun Jan 27 13:58:27 EST 2008


> The `trheading` module is modeled after Java's threading API.

OK. Thanks for the hint. However BufferedReader.readline() does
not block in Java, so it is still difficult to transpose.

>> But how can I find out *programmatically* that there is no more
>> input?
> 
> You can't.

How do people handle this, then? Reading from a process that will
block if you ask too much yet won't let you know how much there is
to read right now has to be some kind of FAQ.

> This doesn't answer if the interpreter doesn't flush its output buffer
> after every line.

I think it must otherwise you might get incomplete answers or no
answers at the interactive prompt and that never happens. It may
not flush its buffer after every line but it must flush them at
the end of an answer.

-- O.L.




More information about the Python-list mailing list