Message406949
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. |
|
Date |
User |
Action |
Args |
2021-11-24 19:02:40 | takluyver | set | recipients:
+ takluyver, asvetlov, yselivanov, jaswdr, kormang |
2021-11-24 19:02:40 | takluyver | set | messageid: <1637780560.3.0.669410883078.issue43806@roundup.psfhosted.org> |
2021-11-24 19:02:40 | takluyver | link | issue43806 messages |
2021-11-24 19:02:40 | takluyver | create | |
|