Author takluyver
Recipients asvetlov, jaswdr, kormang, takluyver, yselivanov
Date 2021-11-24.19:02:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1637780560.3.0.669410883078.issue43806@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-11-24 19:02:40takluyversetrecipients: + takluyver, asvetlov, yselivanov, jaswdr, kormang
2021-11-24 19:02:40takluyversetmessageid: <1637780560.3.0.669410883078.issue43806@roundup.psfhosted.org>
2021-11-24 19:02:40takluyverlinkissue43806 messages
2021-11-24 19:02:40takluyvercreate