Open rutsky opened 7 years ago
A similar issue has been reported (#390), and the hanging problem has been fixed in PR #391. However, you still need to attach the event loop to the child watcher explicitly in order to manage subprocesses without relying on the asyncio policy to provide the event loop (specific to Unix):
asyncio.set_event_loop(None)
loop = asyncio.new_event_loop()
asyncio.get_child_watcher().attach_loop(loop)
Also related: #421, see this comment.
@vxgmichel thanks for the information!
Attaching loop to the child watcher helps.
So this is already fixed and will be included in the next Python 3.5 release?
If I set global event loop to None (
asyncio.set_event_loop(None)
) and explicitly pass everywhere event loop,asyncio.create_subprocess_exec
with I/O redirection will hang.In following example
proc.communicate()
will never return:With
PYTHONASYNCIODEBUG=x
:Tested on Ubuntu 16.04, with Python 3.5.2.