Thomas Kluyver <[email protected]> added the comment:
In the example script, I believe you need to close the write end of the pipe in
the parent after forking:
cpid = os.fork()
if cpid == 0:
# Write to pipe (child)
else:
# Parent
os.close(ctx)
# Read from pipe
This is the same with synchronous code: os.read(prx, 1) also hangs. You only
get EOF when nothing has the write end open any more. All the asyncio machinery
doesn't really make any difference to this.
For a similar reason, the code writing (the child, in this case) should close
the read end of the pipe after forking. If the parent goes away but the child
still has the read end open, then trying to write to the pipe can hang (if the
buffer is already full). If the child has closed the read end, trying to write
will give you a BrokenPipeError.
----------
nosy: +takluyver
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue43806>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com