mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
[3.13] gh-120221: Support KeyboardInterrupt in asyncio REPL (GH-123795) (#123799)
This switches the main pyrepl event loop to always be non-blocking so that it
can listen to incoming interruptions from other threads.
This also resolves invalid display of exceptions from other threads
(gh-123178).
This also fixes freezes with pasting and an active input hook.
(cherry picked from commit 033510e11d
)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
66b15381f1
commit
5c3078d6e5
8 changed files with 133 additions and 21 deletions
|
@ -242,6 +242,7 @@ class TestInteractiveInterpreter(unittest.TestCase):
|
|||
def test_asyncio_repl_is_ok(self):
|
||||
m, s = pty.openpty()
|
||||
cmd = [sys.executable, "-I", "-m", "asyncio"]
|
||||
env = os.environ.copy()
|
||||
proc = subprocess.Popen(
|
||||
cmd,
|
||||
stdin=s,
|
||||
|
@ -249,7 +250,7 @@ class TestInteractiveInterpreter(unittest.TestCase):
|
|||
stderr=s,
|
||||
text=True,
|
||||
close_fds=True,
|
||||
env=os.environ,
|
||||
env=env,
|
||||
)
|
||||
os.close(s)
|
||||
os.write(m, b"await asyncio.sleep(0)\n")
|
||||
|
@ -270,7 +271,7 @@ class TestInteractiveInterpreter(unittest.TestCase):
|
|||
proc.kill()
|
||||
exit_code = proc.wait()
|
||||
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertEqual(exit_code, 0, "".join(output))
|
||||
|
||||
class TestInteractiveModeSyntaxErrors(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue