Title: 3.11.5 regression: StreamWriter.__del__ fails if event loop is already closed · Issue #109538 · python/cpython · GitHub
Open Graph Title: 3.11.5 regression: StreamWriter.__del__ fails if event loop is already closed · Issue #109538 · python/cpython
X Title: 3.11.5 regression: StreamWriter.__del__ fails if event loop is already closed · Issue #109538 · python/cpython
Description: Bug report Bug description: PR #107650 added a StreamWriter.__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 al...
Open Graph Description: Bug report Bug description: PR #107650 added a StreamWriter.__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...
X Description: Bug report Bug description: PR #107650 added a StreamWriter.__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...
Opengraph URL: https://github.com/python/cpython/issues/109538
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"3.11.5 regression: StreamWriter.__del__ fails if event loop is already closed","articleBody":"# Bug report\n\n### Bug description:\n\nPR #107650 added a `StreamWriter.__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).\n\nCode 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`):\n\n```python\n#!/usr/bin/env python3\n\nimport asyncio\n\nasync def main():\n global writer\n reader, writer = await asyncio.open_connection(\"127.0.0.1\", 22)\n\nasyncio.run(main())\n```\n\nOutput in 3.11.5:\n```\nException ignored in: \u003cfunction StreamWriter.__del__ at 0x7fd54ee11080\u003e\nTraceback (most recent call last):\n File \"/usr/lib/python3.11/asyncio/streams.py\", line 396, in __del__\n File \"/usr/lib/python3.11/asyncio/streams.py\", line 344, in close\n File \"/usr/lib/python3.11/asyncio/selector_events.py\", line 860, in close\n File \"/usr/lib/python3.11/asyncio/base_events.py\", line 761, in call_soon\n File \"/usr/lib/python3.11/asyncio/base_events.py\", line 519, in _check_closed\nRuntimeError: Event loop is closed\n```\n\n### CPython versions tested on:\n\n3.11\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-111983\n* gh-112141\n* gh-112142\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/bmerry","@type":"Person","name":"bmerry"},"datePublished":"2023-09-18T13:04:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/109538/cpython/issues/109538"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a519ce03-5452-3091-eb9c-bf5b95361e31 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 967E:10F1EB:1E0A68F:2A34494:696A5A2F |
| html-safe-nonce | 215e2575853ac4099125495311c37a7b23ca0cb3084f311d77294726cdeda37a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjdFOjEwRjFFQjoxRTBBNjhGOjJBMzQ0OTQ6Njk2QTVBMkYiLCJ2aXNpdG9yX2lkIjoiODMxODY2OTYwMDQyOTA3MDg5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 924374de01c4d8e06f6752b65635e32c85cd3907e5fc9c51420d7c3f5e535759 |
| hovercard-subject-tag | issue:1900895533 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/109538/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d3e0c9ba0dd27867099351ade5ca8215d35b197009d1f58847bc373458177ddd/python/cpython/issues/109538 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d3e0c9ba0dd27867099351ade5ca8215d35b197009d1f58847bc373458177ddd/python/cpython/issues/109538 |
| og:image:alt | Bug report Bug description: PR #107650 added a StreamWriter.__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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bmerry |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3f871c8e07f0ae1886fa8dac284166d28b09ad5bada6476fc10b674e489788ef |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 63c426b30d262aba269ef14c40e3c817b384cd61 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width