This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 takluyver
收信人 asvetlov, jaswdr, kormang, takluyver, yselivanov
日期 2021-11-24.19:02:40
SpamBayes Score -1.0
Marked as misclassified
Message-id <1637780560.3.0.669410883078.issue43806@roundup.psfhosted.org>
In-reply-to
内容
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.
历史
日期 用户 动作 参数
2021-11-24 19:02:40takluyver修改recipients: + takluyver, asvetlov, yselivanov, jaswdr, kormang
2021-11-24 19:02:40takluyver修改messageid: <1637780560.3.0.669410883078.issue43806@roundup.psfhosted.org>
2021-11-24 19:02:40takluyver链接issue43806 messages
2021-11-24 19:02:40takluyver创建