Uh oh!
There was an error while loading. Please reload this page.
gh-83069: Use efficient event-driven subprocess.Popen.wait() on Linux / macOS / BSD - #144047
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
giampaolo
commented
Jan 21, 2026
Thanks for the review @vstinner. I addressed your comments. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
giampaolo
commented
Jan 22, 2026
Whops! I fixed the remaining bare |
vstinner
commented
Jan 22, 2026
@gpshead: Do you want to double check the change? |
In the hope of adding BSD / macOS support for |
Uh oh!
There was an error while loading. Please reload this page.
vstinner
commented
Jan 28, 2026
Merged, thank you for this nice optimization! |
…on Linux / macOS / BSD (python#144047)
This patch replaces the busy-loop mechanism used by
subprocess.Popen.wait()on Linux, BSD, and macOS when a timeout is specified:os.pidfd_open()+select.poll()select.kqueue()+KQ_FILTER_PROC+KQ_NOTE_EXITThe kernel wakes us up exactly when the PID terminates or the timeout expires. If the fast-wait mechanisms is not available or fails (e.g. "too many open files"), the function falls back to the traditional busy loop. A similar approach was recently implemented in psutil (see giampaolo/psutil#2706). While working on that change, I noticed that the subprocess module used essentially the same busy-loop strategy, which motivated this proposal.
EDIT: I wrote a blog post about this: https://gmpy.dev/blog/2026/event-driven-process-waiting