-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to perform operation on <WriteUnixTransport closed=True reading=False 0x7f16825f8ba0 #506
Comments
got the same issue with 0.16 |
got the issue when using aiomysql, probably the issue people are facing with aiomysql and uvloop seems to be related to this issue here. Maybe the information posted in the aiomysql issue helps if someone takes this over. |
@1st1 We talked at PyCon US this year. 👋 I said I would create an issue about it... The issue is this one. Let me share an MRE: import asyncio
class EchoServerProtocol(asyncio.Protocol):
def connection_made(self, transport: asyncio.Transport): # type: ignore
self.transport = transport
def data_received(self, data: bytes):
message = data.decode()
print("Data received: {!r}".format(message))
self.transport.close()
# We introduce a short wait to ensure closure processing
asyncio.ensure_future(self.write_after_closure(data))
async def write_after_closure(self, data: bytes):
print(self.transport)
# uvloop: <TCPTransport closed=True reading=False 0x153e33aa0>
# asyncio: <_SelectorSocketTransport closed fd=7>
self.transport.write(data)
# uvloop: RuntimeError
# asyncio: no error
def connection_lost(self, exc: Exception | None):
print("The client connection lost")
async def main():
loop = asyncio.get_running_loop()
server = await loop.create_server(EchoServerProtocol, "127.0.0.1", 8888)
async with server:
await server.serve_forever()
# import uvloop
# asyncio.run(main(), loop_factory=uvloop.new_event_loop, debug=True)
asyncio.run(main()) Uncomment the lines above to see the difference in behavior. You can use any client to call You can also use this small client script, if you want to try things as well... import asyncio
async def tcp_echo_client(message: str):
reader, writer = await asyncio.open_connection("127.0.0.1", 8888)
print(f"Send: {message!r}")
writer.write(message.encode())
data = await reader.read(100)
print(f"Received: {data.decode()!r}")
print("Close the connection")
writer.close()
await writer.wait_closed()
asyncio.run(tcp_echo_client("Hello, World!")) cc @fantix for visibility. |
PYTHONASYNCIODEBUG
in env?: yesThe text was updated successfully, but these errors were encountered: