read stdout/stderr without blocking

Peter Hansen peter at engcorp.com
Tue Sep 13 08:07:57 EDT 2005


Jacek Popławski wrote:
> Grant Edwards wrote:
> 
>> On 2005-09-12, Jacek Pop?awski <jpopl at interia.pl> wrote:
>>
>>>>        ready = select.select(tocheck, [], [], 0.25) ##continues 
>>>> after 0.25s
>>>>        for file in ready[0]:
>>>>            try:
>>>>                text = os.read(file, 1024)
>>>
>>>
>>> How do you know here, that you should read 1024 characters?
>>> What will happen when output is shorter?
>>
>> It will return however much data is available.
> 
> My tests showed, that it will block.

Not if you use non-blocking sockets, as I believe you are expected to 
when using select().

-Peter



More information about the Python-list mailing list