Okay, let KeyboardInterrupt through

This commit is contained in:
Jean-Paul Calderone 2020-12-16 20:32:04 -05:00
parent 895ba55cf7
commit 0ffbc7870e
2 changed files with 14 additions and 1 deletions

View File

@ -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()

View File

@ -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):