-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
work around new Popen.send_signal behavior in Python 3.9
In Python 3.9, Popen.send_signal (which is called by Popen.kill, which we call in SharedChild.kill) now calls Popen.poll first, as a best-effort check to make sure the child's PID hasn't already been freed for reuse. If the child has exited, this may reap the child. Previously we didn't check for this, and we called os.waitid after kill assuming the child was still avilable. Now in Python 3.9 this raises an uncaught "no child found" exception. It's a race condition that only triggers if the child has exited before kill is called. We got lucky and caught this crash in a doctest in CI. An example failing run: https://github.com/oconnor663/duct.py/runs/1488376578 The upstream bug tracking the send_signal change is https://bugs.python.org/issue38630. This commit does a few things: 1. Add a test that reliably triggers the crash. 2. Read Popen.returncode directly, instead of tracking our own SharedChild._status. This makes the test pass, but it's unclear whether it's robust to all possible race conditions. 3. Stop calling Popen.kill, and instead reimplement its previous non-polling behavior. Technically this means we don't need the returncode fix above, but the code is simpler that way anyway, and it's some insurance against more changes like this in future Python versions.
- Loading branch information
1 parent
07010e2
commit 5dfae70
Showing
2 changed files
with
73 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters