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.

Author minrk
Recipients Gabriel Mesquita Cangussu, minrk, mjpieters, paul.moore, steve.dower, terry.reedy, tim.golden, yselivanov, zach.ware
Date 2022-02-23.10:03:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645610597.2.0.667849546302.issue26832@roundup.psfhosted.org>
In-reply-to
Content
It appears that connect_read_pipe also doesn't accept pipes returned by `os.pipe`. If that's the case, what _does_ ProactorEventLoop.connect_read_pipe accept? I haven't been able to find any examples of `connect_read_pipe` that work on Windows, and every connect_read_pipe call in the cpython test suite appears to be skipped on win32. Should it still be raising NotImplementedError on ProactorEventLoop?

I think the error handling could be better (I only get logged errors, nothing I can catch/handle). It seems like `connect_read_pipe` itself should raise when it fails to register the pipe with IOCP. If that's not feasible, connection_lost/transport.close should probably be triggered, but it isn't with Python 3.9, at least.

Example that works on posix, but seems to fail with non-catchable errors with ProactorEventLoop:

```
import asyncio
import os
import sys

class PipeProtocol(asyncio.Protocol):
    def __init__(self):
        self.finished = asyncio.Future()

    def connection_made(self, transport):
        print("connection made", file=sys.stderr)
        self.transport = transport

    def connection_lost(self, exc):
        print("connection lost", exc, file=sys.stderr)
        self.finished.set_result(None)

    def data_received(self, data):
        print("data received", data, file=sys.stderr)
        self.handler(data)

    def eof_received(self):
        print("eof received", file=sys.stderr)
        self.finished.set_result(None)

async def test():
    r, w = os.pipe()
    rf = os.fdopen(r, 'r')
    x, p = await asyncio.get_running_loop().connect_read_pipe(PipeProtocol, rf)
    await asyncio.sleep(1)
    print("writing")
    os.write(w, b'asdf')
    await asyncio.sleep(2)
    print("closing")
    os.close(w)
    await asyncio.wait([p.finished], timeout=3)
    x.close()

if __name__ == "__main__":
    asyncio.run(test())
```
History
Date User Action Args
2022-02-23 10:03:17minrksetrecipients: + minrk, terry.reedy, paul.moore, mjpieters, tim.golden, zach.ware, yselivanov, steve.dower, Gabriel Mesquita Cangussu
2022-02-23 10:03:17minrksetmessageid: <1645610597.2.0.667849546302.issue26832@roundup.psfhosted.org>
2022-02-23 10:03:17minrklinkissue26832 messages
2022-02-23 10:03:17minrkcreate