Skip to content

python -m asyncio and breakpoint() will fovever error loop and mess up the terminal #138827

Description

@yihong0618

Bug report

Bug description:

# Add a code block here, if required
➜  cpython git:(main) ./python.exe -m asyncio
asyncio REPL 3.15.0a0 (heads/hy/close_new_repl_error_mess:b194f8fae6, Sep 12 2025, 19:50:01) [Clang 17.0.0 (clang-1700.0.13.5)] on darwin
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> breakpoint()
> <python-input-0>(1)<module>()
(Pdb) n
--Return--
> <python-input-0>(1)<module>()->None
(Pdb) n
> /Users/yihong/repos/cpython/Lib/asyncio/__main__.py(57)callback()
-> if not inspect.iscoroutine(coro):
(Pdb) n
> /Users/yihong/repos/cpython/Lib/asyncio/__main__.py(58)callback()
-> future.set_result(coro)
(Pdb)

then type n twice the terminal will boom

Image

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Activity

  1. yihong0618 commented on Sep 12, 2025

    @yihong0618
    ContributorAuthor

    because the poll is not thread safe

    this patch #138617 seems also fix this

    cc @picnixz

    and I do not know how a pull request link two issues..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions