##// END OF EJS Templates
Added comments explaining the SIGINT timer
Siyu Zhang -
Show More
@@ -124,16 +124,21 b' def create_inputhook_qt4(mgr, app=None):'
124 ignore_CTRL_C()
124 ignore_CTRL_C()
125 got_kbdint[0] = True
125 got_kbdint[0] = True
126 mgr.clear_inputhook()
126 mgr.clear_inputhook()
127
128 # This generates a second SIGINT so the user doesn't have to
129 # press CTRL+C twice to get a clean prompt.
130 #
131 # Since we can't catch the resulting KeyboardInterrupt here
132 # (because this is a ctypes callback), we use a timer to
133 # generate the SIGINT after we leave this callback.
134 #
135 # Unfortunately this doesn't work on Windows (SIGINT kills
136 # Python and CTRL_C_EVENT doesn't work).
127 if(os.name == 'posix'):
137 if(os.name == 'posix'):
128 pid = os.getpid()
138 pid = os.getpid()
129 print("^C")
130
131 if(not sigint_timer[0]):
139 if(not sigint_timer[0]):
132 sigint_timer[0] = threading.Timer(.01,
140 sigint_timer[0] = threading.Timer(.01, os.kill,
133 os.kill,
141 args=[pid, signal.SIGINT] )
134 args=[pid, signal.SIGINT]
135 )
136
137 sigint_timer[0].start()
142 sigint_timer[0].start()
138 else:
143 else:
139 print("\nKeyboardInterrupt - Ctrl-C again for new prompt")
144 print("\nKeyboardInterrupt - Ctrl-C again for new prompt")
General Comments 0
You need to be logged in to leave comments. Login now