Mike Frysinger <vap...@users.sourceforge.net> added the comment:

if threading.active_count() returns 1, then you know there's one thread, and 
you're it, so it's not racey, and a lock ins't needed.

thinking a bit more, what if the code just use a recursive lock ?  that would 
restore the single threaded status quo without overly complicating the code.

thinking a bit more, i think you're right that this is inherently racy, but not 
because using the APIs in async context isn't permissible.  if a signal is 
delivered after Popen.wait() finishes the OS waitpid call, but before it 
releases the lock, then the child state is not recoverable from the signal 
handler.

in our case, we're using the signal handler to kill the process, and we want to 
make sure it's exited, so being able to get the exact exit status is not 
important to us, just making sure we can detect when the process is gone.

----------

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

Reply via email to