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

Search Discussions

  • Flyzone at Jun 12, 2007 at 12:54 pm

    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)

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 12, '07 at 12:16p
activeJun 12, '07 at 12:54p
posts2
users1
websitepython.org

1 user in discussion

Flyzone: 2 posts

People

Translate

site design / logo © 2022 Grokbase