[issue38591] Deprecate Process Child Watchers

Andrew Svetlov report at bugs.python.org
Fri Oct 25 18:05:39 EDT 2019


Andrew Svetlov <andrew.svetlov at gmail.com> added the comment:

ThreadedChildWatcher starts a thread per process but has O(1) complexity.

MultiLoopChildWatcher doesn't spawn threads, it can be used safely with asyncio loops spawn in multiple threads. The complexity is O(N) plus no other code should contest for SIG_CHLD subscription.

FastChildWatcher has O(1), this is the good news. All others are bad: the watcher conflicts even with blocking `subprocess.wait()` call, even if the call is performed from another thread.

SafeChildWatcher is safer than FastChildWatcher but working with asyncio subprocess API is still super complicated if asyncio code is running from multiple threads. SafeChildWatcher works well only if asyncio is run from the main thread only. Complexity is O(N).

I think FastChildWatcher and SafeChildWatcher should go, ThreadedChildWatcher should be kept default and MultiLoopChildWatcher is an option where ThreadedChildWatcher is not satisfactory.

MultiLoopChildWatcher problems can and should be fixed; there is nothing bad in the idea but slightly imperfect implementation.

Regarding pidfd and kqueue -- I love to see pull requests with proposals. Now nothing exists.
The pidfd is available starting from the latest released Linux 5.3;  we need to wait for a decade before all Linux distros adopt it and we can drop all other implementations.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38591>
_______________________________________


More information about the Python-bugs-list mailing list