Repository navigation
Resuming python -m asyncio process is not properly handled on Unix-like platforms #139391
Copy link
Copy link
Closed
Closed
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesOS-linuxOS-macstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
The resumed REPL can't be exited on Unix-like platforms other than through kill:
./python.exe -m asyncio
ctrl + z
fg
# then the terminal boom
>>>
Traceback (most recent call last):
File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/readline.py", line 395, in multiline_input
return reader.readline()
~~~~~~~~~~~~~~~^^
File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/reader.py", line 752, in readline
self.restore()
~~~~~~~~~~~~^^
File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/reader.py", line 608, in restore
self.console.restore()
~~~~~~~~~~~~~~~~~~~~^^
File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/unix_console.py", line 377, in restore
signal.signal(signal.SIGWINCH, self.old_sigwinch)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/signal.py", line 58, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread of the main interpreter
>>>
Traceback (most recent call last):
File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/readline.py", line 395, in multiline_input
return reader.readline()
~~~~~~~~~~~~~~~^^
File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/reader.py", line 752, in readline
self.restore()
~~~~~~~~~~~~^^
File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/reader.py", line 608, in restore
self.console.restore()
~~~~~~~~~~~~~~~~~~~~^^
File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/unix_console.py", line 377, in restore
signal.signal(signal.SIGWINCH, self.old_sigwinch)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/signal.py", line 58, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread of the main interpreter
>>>
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-139391: properly handle
signal.signal()inUnixConsolewhen called from a non-main thread #139392 - [3.14] gh-139391: properly handle
signal.signal()inUnixConsolewhen called from a non-main thread (GH-139392) #139858 - [3.13] gh-139391: properly handle
signal.signal()inUnixConsolewhen called from a non-main thread (GH-139392) #139861
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesOS-linuxOS-macstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
yihong0618 commentedon Sep 29, 2025
update
linux can also have this problem
[-]python -m asyncio then Ctrl + z then fg will break the repl and raise error forever[/-][+]Resuming `python -m asyncio` process is not properly handled[/+][-]Resuming `python -m asyncio` process is not properly handled[/-][+]Resuming `python -m asyncio` process is not properly handled on Unix-like platforms[/+]gh-139391: properly handle `signal.signal()` in `UnixConsole` when ca…
[3.13] pythongh-139391: properly handle `signal.signal()` in `UnixCon…
pythongh-139391: properly handle `signal.signal()` in `UnixConsole` w…
[3.14] gh-139391: properly handle `signal.signal()` in `UnixConsole` …
[3.13] gh-139391: properly handle `signal.signal()` in `UnixConsole` …