Skip to content
This repository

don't ignore ctrl-C during `%gui qt` #1160

Merged
merged 2 commits into from over 2 years ago

3 participants

Min RK Fernando Perez Christian Boos
Min RK
Owner

See #1157

PR #815 ignores ctrl-C during normal code execution, this restores the sigint handler outside the inputhook.

Fernando Perez fperez merged commit 464cb89 into from December 15, 2011
Fernando Perez fperez closed this December 15, 2011
Fernando Perez
Owner

@cboos, just wanted to ping you on this one: we merged it after review on IRC and a fair amount of testing. We realize it may bring back some problem case you might know about and that we couldn't find, so please let us know if that's the case. But the complete breakage of C-C in master was bad enough that we had to do something to fix it; we're happy to fine-tune further if you know of other edge cases this causes problems with.

Christian Boos

Thanks for the CC. The changes look good and a0e0692 was indeed a mistake from my part, the correct behavior should indeed be that CTRL+C is allowed outside of the inputhook (I probably did this silly mistake in an "afterthought", wanting to make it symmetric with the ignore_CTRL_C in the catch block, forgetting that the mgr.clear_inputhook() done just a bit later would reenable the CTRL_C). Your finally clause makes the intent clearer.

Christian Boos

That mgr.clear_inputhook() will re-enable the CTRL+C, so any KeyboardInterrupt received in the few lines until the function exit may risk to result in an other internal error, so it's probably best to move that call till after print("Got exception...").

Owner

Good catch, thanks! Fixed in 699fdb4.

Fernando Perez fperez referenced this pull request from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 4 additions and 6 deletions. Show diff stats Hide diff stats

  1. 10  IPython/lib/inputhookqt4.py
10  IPython/lib/inputhookqt4.py
@@ -91,21 +91,19 @@ def inputhook_qt4():
91 91
                     timer.start(50)
92 92
                     app.exec_()
93 93
                     timer.stop()
94  
-            ignore_CTRL_C()
95 94
         except KeyboardInterrupt:
96 95
             ignore_CTRL_C()
97 96
             got_kbdint[0] = True
98  
-            print("\nKeyboardInterrupt - qt4 event loop interrupted!"
99  
-                  "\n  * hit CTRL+C again to clear the prompt"
100  
-                  "\n  * use '%gui none' to disable the event loop"
101  
-                  " permanently"
102  
-                  "\n    and '%gui qt4' to re-enable it later")
  97
+            print("\nKeyboardInterrupt - Ctrl-C again for new prompt")
103 98
             mgr.clear_inputhook()
104 99
         except: # NO exceptions are allowed to escape from a ctypes callback
  100
+            ignore_CTRL_C()
105 101
             mgr.clear_inputhook()
106 102
             from traceback import print_exc
107 103
             print_exc()
108 104
             print("Got exception from inputhook_qt4, unregistering.")
  105
+        finally:
  106
+            allow_CTRL_C()
109 107
         return 0
110 108
 
111 109
     def preprompthook_qt4(ishell):
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.