how to set timeout for os.popen

Ho Yeung Lee jobmattcon at gmail.com
Sun Apr 15 07:01:21 EDT 2018


while 1:
runner = os.popen("tracert -d www.hello.com")
o=runner.read()
print(o)
runner.close()
runner = os.popen("tracert -d www.hello.com")
o=runner.read()
print(o)
runner.close()
runner = os.popen("tracert -d www.hello.com")
o=runner.read()
print(o)
runner.close()


after running over 1 hour, it stop and not return in one of tracert

how to set timeout and know that this is timeout?



More information about the Python-list mailing list