[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:
Miss Islington (bot) 2024-09-06 22:25:19 +02:00 committed by GitHub
parent 66b15381f1
commit 5c3078d6e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 133 additions and 21 deletions

View file

@ -479,7 +479,7 @@ class WindowsConsole(Console):
while True:
if msvcrt.kbhit(): # type: ignore[attr-defined]
return True
if timeout and time.time() - start_time > timeout:
if timeout and time.time() - start_time > timeout / 1000:
return False
time.sleep(0.01)