Skip to content

Eliminate busy-loop in Process.wait() on Linux and BSD#2706

Merged
giampaolo merged 53 commits intomasterfrom
faster-wait-pid
Jan 17, 2026
Merged

Eliminate busy-loop in Process.wait() on Linux and BSD#2706
giampaolo merged 53 commits intomasterfrom
faster-wait-pid

Conversation

@giampaolo
Copy link
Copy Markdown
Owner

@giampaolo giampaolo commented Jan 17, 2026

Summary

Description

  • Linux: Process.wait() now uses pidfd_open() + poll() instead of busy-loop polling. Requires Linux >= 5.3, Python >= 3.9.
  • macOS/BSD: Process.wait() now uses kqueue() instead of busy-loop polling.
  • Both implementations fall back to traditional busy loop polling if not available or on certain errors.

EDIT: this change has been proposed for inclusion into cPython: python/cpython#144047.

EDIT: this change was turned into a blogpost: https://gmpy.dev/blog/2026/event-driven-process-waiting.

@github-actions github-actions bot added the linux label Jan 17, 2026
@giampaolo giampaolo merged commit 77d0a4a into master Jan 17, 2026
27 checks passed
@giampaolo giampaolo deleted the faster-wait-pid branch January 17, 2026 01:55
@giampaolo
Copy link
Copy Markdown
Owner Author

This change has been proposed for inclusion in cPython: python/cpython#144047.

@giampaolo
Copy link
Copy Markdown
Owner Author

This change was turned into a blogpost: https://gmpy.dev/blog/2026/event-driven-process-waiting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux, macOS, BSD] speedup Process.wait()

1 participant