# HG changeset patch # Parent b382206aeb2b0859398ded149527fbea47c8ddde bpo-29926: Send a real SIGINT to the main thread in Idle on Unix Seems to work with normal blocking calls like “sleep” and “os.read”, and a tight “for” loop, but does not work with “input()” or “sys.stdin.readline()”. diff -r b382206aeb2b -r f8eebc3d6301 Lib/idlelib/run.py --- a/Lib/idlelib/run.py Fri Feb 03 11:08:45 2017 +0800 +++ b/Lib/idlelib/run.py Mon Apr 03 03:16:36 2017 +0000 @@ -1,6 +1,7 @@ import io import linecache import queue +import signal import sys import time import traceback @@ -108,7 +109,9 @@ global exit_now global quitting global no_exitfunc + global main_thread no_exitfunc = del_exitfunc + main_thread = threading.get_ident() #time.sleep(15) # test subprocess not responding try: assert(len(sys.argv) > 1) @@ -478,7 +481,10 @@ def interrupt_the_server(self): if interruptable: - thread.interrupt_main() + try: # Unix + signal.pthread_kill(main_thread, signal.SIGINT) + except AttributeError: # Fallback on Windows + thread.interrupt_main() def start_the_debugger(self, gui_adap_oid): return debugger_r.start_debugger(self.rpchandler, gui_adap_oid)