FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-92841: Fix asyncio's RuntimeError: Event loop is closed by arhadthedev · Pull Request #92842 · python/cpython · GitHub

/ cpython Public

gh-92841: Fix asyncio's RuntimeError: Event loop is closed - #92842

Merged
zooba merged 2 commits into
python:mainfrom
arhadthedev:asyncio-__del__-runtimeerror
May 17, 2022
Merged

gh-92841: Fix asyncio's RuntimeError: Event loop is closed#92842
zooba merged 2 commits into
python:mainfrom
arhadthedev:asyncio-__del__-runtimeerror

Conversation

arhadthedev commented May 16, 2022
edited
Loading

Copy link
Copy Markdown
Member

Both asyncio.selector_events._SelectorTransport and asyncio.proactor_events._ProactorBasePipeTransport check if an associated socket is left unclosed and emit a warning on a positive answer.

However, further behavior differs. While _SelectorTransport closes the socket:

def __del__(self, _warn=warnings.warn):
    if self._sock is not None:
        _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
        self._sock.close()

the _ProactorBasePipeTransport attempts to close itself leaving the socked leaked:

def __del__(self, _warn=warnings.warn):
    if self._sock is not None:
        _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
        self.close()

It looks like there was no plan to close the transport itself causing <already closed parent loop>.call_soon().

The deleters were introduced by 978a9af with no explanatory comment about the implementation difference.

Fixes (no autoclose) gh-92841, gh-91233, and gh-83413. Probably fixes (no autoclose) gh-81562.

Copy link
Copy Markdown
Member Author

Note that the NEWS entry uses socket activity instead of pipe activity because _ProactorBasePipeTransport affects sockets via its inheritance chain:

classDiagram
_ProactorBasePipeTransport <|-- _ProactorReadPipeTransport
_ProactorBasePipeTransport <|-- _ProactorBaseWritePipeTransport
_ProactorBasePipeTransport <|-- _ProactorDatagramTransport
_ProactorReadPipeTransport <|-- _ProactorDuplexPipeTransport
_ProactorBaseWritePipeTransport <|-- _ProactorDuplexPipeTransport
_ProactorReadPipeTransport <|-- _ProactorSocketTransport
_ProactorBaseWritePipeTransport <|-- _ProactorSocketTransport
Loading

…x107.rst

Co-authored-by: Steve Dower <steve.dower@microsoft.com>
zooba merged commit 33880b4 into python:main May 17, 2022
zooba added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels May 17, 2022

Copy link
Copy Markdown
Contributor

Thanks @arhadthedev for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

Copy link
Copy Markdown
Contributor

Thanks @arhadthedev for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 17, 2022
…honGH-92842)

(cherry picked from commit 33880b4)

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
bedevere-bot removed the needs backport to 3.10 only security fixes label May 17, 2022

Copy link
Copy Markdown

GH-92904 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 17, 2022
…honGH-92842)

(cherry picked from commit 33880b4)

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
bedevere-bot removed the needs backport to 3.11 only security fixes label May 17, 2022

Copy link
Copy Markdown

GH-92905 is a backport of this pull request to the 3.11 branch.

miss-islington added a commit that referenced this pull request May 17, 2022
(cherry picked from commit 33880b4)

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
arhadthedev deleted the asyncio-__del__-runtimeerror branch May 18, 2022 03:35
ambv pushed a commit that referenced this pull request Jun 28, 2022
…GH-92904)

(cherry picked from commit 33880b4)

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL