Message298736
This is a race condition — when os.kill returns, that means that the signal has been delivered, but it does not mean that the subprocess has exited yet. You can see this by inserting a sleep after the kill and before the liveness check:
print(proc.is_alive())
os.kill(proc.pid, signal.SIGTERM)
time.sleep(1)
print(proc.is_alive())
This (probably) gives the process time to exit. (Presumably the psutil.pid_exists() call has a similar effect.) Of course, waiting for 1 second (or any amount of time) might not be enough. The right thing to do is to join the process. Then when the join exits you know it died. |
|
Date |
User |
Action |
Args |
2017-07-20 17:13:20 | gdr@garethrees.org | set | recipients:
+ gdr@garethrees.org, paul.moore, tim.golden, zach.ware, steve.dower, davin, mickp |
2017-07-20 17:13:20 | gdr@garethrees.org | set | messageid: <1500570800.58.0.364811387228.issue30976@psf.upfronthosting.co.za> |
2017-07-20 17:13:20 | gdr@garethrees.org | link | issue30976 messages |
2017-07-20 17:13:20 | gdr@garethrees.org | create | |
|