Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Asyncio stream doesn't handle exceptions in callback #110894

Closed
Assignees
kumaraditya303
Labels
3.11only security fixes3.12only security fixes3.13bugs and security fixestopic-asynciotype-bugAn unexpected behavior, bug, or error
@LasseBlaauwbroek

Description

@LasseBlaauwbroek

Bug report

Bug description:

Consider the following server that always just crashes:

importasyncioasyncdefhandle_echo(reader,writer):raiseException("I break everything")asyncdefmain():server=awaitasyncio.start_server(handle_echo,'127.0.0.1',8888)asyncwithserver:awaitserver.serve_forever()asyncio.run(main(),debug=True)

Together with the following client:

importasyncioasyncdeftcp_echo_client(message):reader,writer=awaitasyncio.open_connection('127.0.0.1',8888)data=awaitreader.read(100)print(data)writer.close()awaitwriter.wait_closed()print("closed")asyncio.run(tcp_echo_client('Hello World!'),debug=True)

When running this in Python 3.8, the server prints aTask exception was never retrieved message with an exception. I guess this is acceptable. However, the connection is never closed, and the client is kept hanging. That should not happen in my opinion.

Furthermore, in newer Python versions, due to#96323, the internal task is being kept alive indefinitely. Therefore, theTask exception was never retrieved message is only printed when you kill the server. Otherwise, the failure is completely silent. This is extremely counter-intuitive behavior.

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixes3.13bugs and security fixestopic-asynciotype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp