Jack O'Connor <oconnor...@gmail.com> added the comment:

This change caused a crash in the Duct library in Python 3.9. Duct uses the 
waitid(NOWAIT) strategy that Nathaniel Smith has described in this thread. With 
this change, the child process is reaped by kill() in a spot we didn't expect, 
and a subsequent call to os.waitid() raises a ChildProcessError. This is a race 
condition that only triggers if the child happens to exit before kill() is 
called.

I just pushed 
https://github.com/oconnor663/duct.py/commit/5dfae70cc9481051c5e53da0c48d9efa8ff71507
 to work around this, which I'll release shortly as Duct version 0.6.4.

Broadly speaking, this change could break any program that uses Popen.kill() 
together with os.waitpid() or os.waitid(). Checking Popen.returncode before 
calling the os functions is a good workaround for the single-threaded case, but 
it doesn't fix the multithreaded case. Duct is going to avoid calling 
Popen.kill() entirely. There are some longer comments about race conditions in 
that commit I linked.

I don't feel strongly one way the other about keeping this new behavior, but we 
should probably document it clearly in Popen.send_signal() and all of its 
callers that these functions might reap the child.

----------
nosy: +oconnor663

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

Reply via email to