Skip to content

asyncio REPL: Use self.loop instead of global loop variable in AsyncIOInteractiveConsole #136447

@injust

Description

@injust

I'm trying to extend the asyncio REPL (yes, I know this is an unsupported use case) by doing the following:

  • from asyncio.__main__ import AsyncIOInteractiveConsole
  • Copy the if __name__ == '__main__' block into my own __main__.py
  • Copy and edit REPLThread (subclassing isn't possible because it also refers to global variables)

However, this doesn't work because AsyncIOInteractiveConsole refers to asyncio.__main__'s global loop variable, despite it being passed and assigned to the instance attribute self.loop.

https://github.com/python/cpython/blob/3.13/Lib/asyncio/__main__.py#L65

I see no reason why AsyncIOInteractiveConsole shouldn't use self.loop consistently.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions