diff --git a/src/allmydata/test/test_observer.py b/src/allmydata/test/test_observer.py index 73eece98e..134876be3 100644 --- a/src/allmydata/test/test_observer.py +++ b/src/allmydata/test/test_observer.py @@ -141,3 +141,16 @@ class Observer(unittest.TestCase): self.assertEqual([None], observed) self.assertEqual(1, len(self.flushLoggedErrors(Exception))) + + def test_observer_list_propagate_keyboardinterrupt(self): + """ + ``KeyboardInterrupt`` escapes ``ObserverList.notify``. + """ + def observer_one(): + raise KeyboardInterrupt() + + obs = observer.ObserverList() + obs.subscribe(observer_one) + + with self.assertRaises(KeyboardInterrupt): + obs.notify() diff --git a/src/allmydata/util/observer.py b/src/allmydata/util/observer.py index ad55e65a5..4a39fe014 100644 --- a/src/allmydata/util/observer.py +++ b/src/allmydata/util/observer.py @@ -118,7 +118,7 @@ class ObserverList(object): for o in self._watchers[:]: try: o(*args, **kwargs) - except: + except Exception: self._logger.failure("While notifying {o!r}", o=o) class EventStreamObserver(object):