Gareth Rees added the comment:

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.

----------
nosy: +g...@garethrees.org

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30976>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to