FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-74112: IDLE: Fix blocking function ignore SIGINT by mlouielu · Pull Request #2466 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
18 changes: 17 additions & 1 deletion Lib/idlelib/run.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import linecache
import queue
import sys
import signal
import textwrap
import time
import traceback
Expand Down Expand Up @@ -106,6 +107,7 @@ def handle_tk_events(tcl=tcl):
exit_now = False
quitting = False
interruptable = False
finish = False

def main(del_exitfunc=False):
"""Start the Python execution server in a subprocess
Expand All @@ -128,6 +130,8 @@ def main(del_exitfunc=False):
global exit_now
global quitting
global no_exitfunc
global main_thread
main_thread = threading.get_ident()
no_exitfunc = del_exitfunc
#time.sleep(15) # test subprocess not responding
try:
Expand Down Expand Up @@ -570,9 +574,10 @@ def __init__(self, rpchandler):
self.locals = {}

def runcode(self, code):
global interruptable
global interruptable, finish
try:
self.user_exc_info = None
finish = False
interruptable = True
try:
exec(code, self.locals)
Expand Down Expand Up @@ -601,11 +606,22 @@ def runcode(self, code):
self.rpchandler.interp.open_remote_stack_viewer()
else:
flush_stdout()
finally:
finish = True

def interrupt_the_server(self):
if interruptable:
thread.interrupt_main()

# See issue 29926, fallback when interrupt_main doesn't work
def _interrupt_by_signal_pthread():
if not finish:
try:
signal.pthread_kill(main_thread, signal.SIGINT)
except AttributeError:
pass
threading.Timer(0.2, _interrupt_by_signal_pthread).start()

def start_the_debugger(self, gui_adap_oid):
return debugger_r.start_debugger(self.rpchandler, gui_adap_oid)

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
IDLE Shell no longer ignores Ctrl+C when an interpreter waits on a
blocking function. Patch by Louie Lu.

Back | FazBrowse Home | New Git URL