diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2007-10-09 19:31:30 (GMT) |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2007-10-09 19:31:30 (GMT) |
commit | c8f65e69da7237e5c0d58afb032e4b0b432b918a (patch) | |
tree | 5a9e92923f684597d1dd0f2a1f38714436166592 /Lib/idlelib/run.py | |
parent | e7f4d8483082d2f694e8a89ec531ab378e6b8326 (diff) | |
download | cpython-c8f65e69da7237e5c0d58afb032e4b0b432b918a.zip cpython-c8f65e69da7237e5c0d58afb032e4b0b432b918a.tar.gz cpython-c8f65e69da7237e5c0d58afb032e4b0b432b918a.tar.bz2 |
Allow interrupt only when executing user code in subprocess
Patch 1225 Tal Einat modified from IDLE-Spoon.
Diffstat (limited to 'Lib/idlelib/run.py')
-rw-r--r-- | Lib/idlelib/run.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index ae810c4..4eb64d6 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -38,10 +38,11 @@ else: # Thread shared globals: Establish a queue between a subthread (which handles # the socket) and the main thread (which runs user code), plus global -# completion and exit flags: +# completion, exit and interruptable (the main thread) flags: exit_now = False quitting = False +interruptable = False def main(del_exitfunc=False): """Start the Python execution server in a subprocess @@ -280,9 +281,14 @@ class Executive(object): self.autocomplete = AutoComplete.AutoComplete() def runcode(self, code): + global interruptable try: self.usr_exc_info = None - exec code in self.locals + interruptable = True + try: + exec code in self.locals + finally: + interruptable = False except: self.usr_exc_info = sys.exc_info() if quitting: @@ -296,7 +302,8 @@ class Executive(object): flush_stdout() def interrupt_the_server(self): - thread.interrupt_main() + if interruptable: + thread.interrupt_main() def start_the_debugger(self, gui_adap_oid): return RemoteDebugger.start_debugger(self.rpchandler, gui_adap_oid) |