##// END OF EJS Templates
address #11630 by catching KeyboardInterrupt from event handlers
jsnydes -
Show More
@@ -86,7 +86,7 b' class EventManager(object):'
86 for func in self.callbacks[event][:]:
86 for func in self.callbacks[event][:]:
87 try:
87 try:
88 func(*args, **kwargs)
88 func(*args, **kwargs)
89 except Exception:
89 except (Exception, KeyboardInterrupt):
90 print("Error in callback {} (for {}):".format(func, event))
90 print("Error in callback {} (for {}):".format(func, event))
91 self.shell.showtraceback()
91 self.shell.showtraceback()
92
92
@@ -51,6 +51,12 b' class CallbackTests(unittest.TestCase):'
51 with tt.AssertPrints("Error in callback"):
51 with tt.AssertPrints("Error in callback"):
52 self.em.trigger('ping_received')
52 self.em.trigger('ping_received')
53
53
54 def test_cb_keyboard_interrupt(self):
55 cb = Mock(side_effect=KeyboardInterrupt)
56 self.em.register('ping_received', cb)
57 with tt.assertPrints("Error in callback"):
58 self.em.trigger('ping_received')
59
54 def test_unregister_during_callback(self):
60 def test_unregister_during_callback(self):
55 invoked = [False] * 3
61 invoked = [False] * 3
56
62
General Comments 0
You need to be logged in to leave comments. Login now