read stdout/stderr without blocking

Adriaan Renting renting at astron.nl
Mon Sep 12 10:09:30 EDT 2005


The line only means it will read a maximum of 1024 characters, most of the output I try to catch is much shorter. I think that if the output is longer as 1024, it will read the rest after another call to select.select, but I think I have not yet come across that case and have not tested it.

I set the error pipe to OS_NONBLOCKing earlier in the code, but I can't remember if that has anything to do with the os.read(). 

Note: I'm using Python 2.3.4/2.3.5, not tested on 2.4.x yet.
 
>>>Jacek Pop*awski <jpopl at interia.pl> 09/12/05 2:39 pm >>> 
>        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? 
-- 
http://mail.python.org/mailman/listinfo/python-list 




More information about the Python-list mailing list