Closed Tinche closed 7 years ago
I ran into this issue at some point, and here is the explanation:
- Only the main thread can register signals, so the child watcher has to be bound to the main loop (the loop running in the main thread).
- It is fine for other loops to watch subprocesses, as long as the main loop is running (so the main loop can notify the other ones using
call_soon_threadsafe
).
This was my conclusion:
From the design point of view, it is up to the policy to decide how the watcher is supposed to run. So if one chooses to go explicit (i.e. set_event_loop(None)), the loop should also be attached explicitly:
asyncio.set_event_loop(None) loop = asyncio.new_event_loop() asyncio.get_child_watcher().attach_loop(loop)
More information in issue #390 and PR #391.
Should we close this one?
Sure, I'll go through the linked issues and see what do to in pytest-asyncio.
Hello,
I'm the maintainer of pytest-asyncio. Pytest-asyncio allows users to block access to the global event loop, and pass the event loop explicitly; this is considered by some in the community as a best-practices approach.
However I've just received a bug report this approach doesn't work with subprocess (on Unix at least). Consider this test:
Two comments: