Summary
- OS: Linux, macOS, BSD
- Type: core
Description
See #2703 (comment).
Process.wait() implementation uses a busy loop with small sleeps, see: https://github.com/giampaolo/psutil/blob/77cfb0c6/psutil/_psposix.py#L61-L154
On Linux, this can be made more efficient by using pidfd_open() and passing the FD to a multiplexor like select(), poll() or epoll().
On BSD and macOS we can use kqueue().
EDIT: this change has been proposed for inclusion into cPython: python/cpython#144047.
Summary
Description
See #2703 (comment).
Process.wait()implementation uses a busy loop with small sleeps, see: https://github.com/giampaolo/psutil/blob/77cfb0c6/psutil/_psposix.py#L61-L154On Linux, this can be made more efficient by using
pidfd_open()and passing the FD to a multiplexor likeselect(),poll()orepoll().On BSD and macOS we can use
kqueue().EDIT: this change has been proposed for inclusion into cPython: python/cpython#144047.