closes bpo-38692: Add a pidfd child process watcher to asyncio. by benjaminp · Pull Request #17069 · python/cpython (original) (raw)

@benjaminp

Well, I'm just reading the docstring you quoted. :)

Yeah, fair point. I had just misunderstood "callback() must be thread-safe", as the invocation and the callback itself must be thread-safe, rather than just the callback. I'm also the most familiar with ThreadedChildWatcher (since that one is the default), where multiple threads are utilized and loop.call_soon_threadsafe() is a must (within its _do_waitpid() method).

cpython/Lib/asyncio/unix_events.py

Line 1325 in5c0c325

loop.call_soon_threadsafe(callback, pid, returncode, *args)