GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — asyncio: ConnectionResetError after StreamWriter is garbage collected · Issue #109321 · python/cpython Closed as not planned Closed as not planned Copy link Labels pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportBug description:The code below works perfectly on Python 3.11.4 but fails with import asyncio HOST = 'ifconfig.me' PORT = 80 async def connect() -> asyncio.Transport: reader, writer = await asyncio.open_connection( host=HOST, port=PORT, ) return writer.transport # type: ignore async def fetch(): loop = asyncio.get_running_loop() transport = await connect() # transport is already closed here on 3.11.5 reader = asyncio.StreamReader(limit=2**16, loop=loop) protocol = asyncio.StreamReaderProtocol(reader, loop=loop) transport.set_protocol(protocol) loop.call_soon(protocol.connection_made, transport) loop.call_soon(transport.resume_reading) writer = asyncio.StreamWriter( transport=transport, protocol=protocol, reader=reader, loop=loop, ) request = f'GET /ip HTTP/1.1\r\nHost: {HOST}\r\nConnection: close\r\n\r\n'.encode() writer.write(request) await writer.drain() response = await reader.read(-1) print(response) writer.close() if __name__ == '__main__': asyncio.run(fetch()) Traceback (most recent call last): File "/home/rigens/aio_test1.py", line 50, in <module> asyncio.run(fetch()) File "/usr/local/miniconda/envs/py311_5/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/local/miniconda/envs/py311_5/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/miniconda/envs/py311_5/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/home/rigens/aio_test1.py", line 41, in fetch await writer.drain() File "/usr/local/miniconda/envs/py311_5/lib/python3.11/asyncio/streams.py", line 378, in drain await self._protocol._drain_helper() File "/usr/local/miniconda/envs/py311_5/lib/python3.11/asyncio/streams.py", line 167, in _drain_helper raise ConnectionResetError('Connection lost') ConnectionResetError: Connection lost CPython versions tested on:3.11 Operating systems tested on:Linux Activity
MetadataMetadataAssigneesLabelspendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error Projects
MilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |