Timeout to readline()/readlines()

H

Horta

Hi folks,
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?

Thanks.
 
H

Hendrik van Rooyen

Horta said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top