Timeout to readline()/readlines()

Hendrik van Rooyen mail at microcorp.co.za
Tue Mar 20 01:49:54 EDT 2007


"Horta" <danilo.horta at gmail.com> wrote:

>  Sometimes, when I do an os.popen*(), the process executed by the
> command hangs, and the script stops forever on the readline()/
> readlines() calls. I found that I can use select, but I'm thinking...
> if, after a sellect() call returns, the stdout (for example) has more
> than one line? or if it has just some characters, no newline, and the
> process just hangs?
> 
>   I just want a readline(timeout) and readlines(timeout) like
> functions. Do I need to create my owns or there're already
> implemented?

you have to unblock the file and use try - except.
look at the fcntl module

- Hendrik




More information about the Python-list mailing list