popen e pclose on python 2.3 question

Flyzone flyzone at technologist.com
Tue Jun 12 08:16:22 EDT 2007


I need to run a network program and return output in a variable name
without use temporany file.
So i tought to use popen (i'm using python 2.3, i can't upgrade).
RESULT = os.popen('command'+HOST, 'r')
I have a problem about it:
i need to kill the child if the program take more than 300 ms, but i
need also to wait this 300 ms to have the reply.
os.pclose(RESULT) give me:
AttributeError: 'module' object has no attribute 'pclose'
cause pclose doens't exist in 2.3.....and a time.wait(0.3) is not a so
clean code.
Someone can give me some tricks? I would like a script portable on
python 2.3, i would not like
to compile on 2.5.




More information about the Python-list mailing list