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: an SSL connection whose peer closes while reading is paused cannot be closed, and its writes are dropped · Issue #161560 · python/cpython Open Labels stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportBug descriptionFor an application that has paused reading from a TLS transport, a This bug was caught during the development of a media server, and can be explained by the following example:
While this example covers repro_issue.py"""A TLS stream server, a client that sends more than the reader's limit and disconnects.""" import asyncio, socket, ssl from test.support import findfile CERT = findfile('keycert.pem', subdir='certdata') async def handler(reader, writer): await asyncio.sleep(0.5) # busy; the reader's buffer is full, so reading is paused writer.close() try: await asyncio.wait_for(writer.wait_closed(), 5) print(' wait_closed() returned') except TimeoutError: print(' wait_closed() still waiting after 5 s, socket', writer.get_extra_info('socket').fileno()) writer.transport.abort() def client(port, tls): s = socket.create_connection(('127.0.0.1', port)) if tls: ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE s = ctx.wrap_socket(s) s.sendall(bytes(8192)) s.settimeout(0.2) try: s.recv(1) # takes in TLS 1.3 session tickets; nothing else is coming except TimeoutError: pass s.close() # an ordinary disconnect async def main(): sctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) sctx.load_cert_chain(CERT) for tls in (False, True): print('TLS' if tls else 'TCP') kw = {'ssl': sctx, 'ssl_shutdown_timeout': 1} if tls else {} server = await asyncio.start_server(handler, '127.0.0.1', 0, limit=1024, **kw) await asyncio.to_thread(client, server.sockets[0].getsockname()[1], tls) await asyncio.sleep(6) server.close() asyncio.run(main()) Important notes about this issue:
The Fix Proposal
It is important to keep returning With three new tests and this proposed fix, This was tested as follows:
Disclosure: I used Claude (Opus 5.5) to trace this, write the reproducers and tests, and run them on my machines. Claude found the bug as well and wrote the candidate fix. I have read and understood the work, and I am fully responsible for this report. CPython versions tested on:3.12, 3.14 Operating systems tested on:macOS, Linux Activity
MetadataMetadataAssigneesLabelsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-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. |