popen e pclose on python 2.3 question

Flyzone flyzone at technologist.com
Tue Jun 12 08:54:55 EDT 2007


> 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.

I reply by myself:

from popen2 import Popen3
cmd = Popen3('command','r')
waiting=0
while (cmd.poll()==-1):
       time.sleep(0.1)
       waiting+=1
       if (waiting>3): os.kill(RESULT.pid,0)




More information about the Python-list mailing list