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

3.11.5 regression: StreamWriter.__del__ fails if event loop is already closed #109538

Closed
Labels
3.11only security fixestopic-asynciotype-bugAn unexpected behavior, bug, or error
@bmerry

Description

@bmerry

Bug report

Bug description:

PR#107650 added aStreamWriter.__del__ that emits a ResourceWarning if a StreamWriter is not closed by the time it is garbage collected, and it has been backported as 3.11.5. However, if the event loop has already been closed by the time this happens, it causes a RuntimeError message to be displayed. It's non-fatal because exceptions raised by__del__ are ignored, but it causes an error message to be displayed to the user (as opposed to ResourceWarning, which is only shown when one opts in).

Code like the following used to run without any visible error, but now prints a traceback (and does not report the ResourceWarning for the unclosed StreamWriter when run with-X dev):

#!/usr/bin/env python3importasyncioasyncdefmain():globalwriterreader,writer=awaitasyncio.open_connection("127.0.0.1",22)asyncio.run(main())

Output in 3.11.5:

Exception ignored in: <function StreamWriter.__del__ at 0x7fd54ee11080>Traceback (most recent call last):  File "/usr/lib/python3.11/asyncio/streams.py", line 396, in __del__  File "/usr/lib/python3.11/asyncio/streams.py", line 344, in close  File "/usr/lib/python3.11/asyncio/selector_events.py", line 860, in close  File "/usr/lib/python3.11/asyncio/base_events.py", line 761, in call_soon  File "/usr/lib/python3.11/asyncio/base_events.py", line 519, in _check_closedRuntimeError: Event loop is closed

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only 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