diff --git a/txtorcon/router.py b/txtorcon/router.py
index 547c321..03b6163 100644
--- a/txtorcon/router.py
+++ b/txtorcon/router.py
@@ -200,8 +200,6 @@ class Router(object):
             )
         returnValue(relay_data)
 
-
-
     # note that exit-policy is no longer included in the
     # microdescriptors by default, so this stuff is mostly here as a
     # historic artifact. If you want to use exit-policy for things
diff --git a/txtorcon/torcontrolprotocol.py b/txtorcon/torcontrolprotocol.py
index 269c72e..9947c94 100644
--- a/txtorcon/torcontrolprotocol.py
+++ b/txtorcon/torcontrolprotocol.py
@@ -11,6 +11,7 @@ from twisted.internet import defer
 from twisted.internet.interfaces import IProtocolFactory
 from twisted.internet.error import ConnectionDone
 from twisted.protocols.basic import LineOnlyReceiver
+from twisted.python.failure import Failure
 
 from zope.interface import implementer
 
@@ -109,7 +110,17 @@ class Event(object):
 
     def got_update(self, data):
         for cb in self.callbacks:
-            cb(data)
+            try:
+                cb(data)
+            except Exception as e:
+                log.err(Failure())
+                log.err(
+                    "Notifying '{callback}' for '{name}' failed: {e}".format(
+                        callback=cb,
+                        name=self.name,
+                        e=e,
+                    )
+                )
 
 
 def unquote(word):

What happens to an exception in event listener?
If an event-handler for an event listener causes an exception, where does it end up going?

diff --git a/test/test_router.py b/test/test_router.py
index 4ddf5c2..de8dd84 100644
--- a/test/test_router.py
+++ b/test/test_router.py
@@ -3,7 +3,7 @@ from datetime import datetime
 from mock import Mock
 
 from twisted.trial import unittest
-from twisted.internet import defer, error
+from twisted.internet import defer
 from twisted.python.failure import Failure
 from twisted.web.client import ResponseDone
 
@@ -253,7 +253,7 @@ class OnionOOTests(unittest.TestCase):
         agent.request = Mock(return_value=defer.succeed(resp))
 
         with self.assertRaises(Exception) as ctx:
-            data = yield self.router.get_onionoo_details(agent)
+            yield self.router.get_onionoo_details(agent)
 
         self.assertTrue(
             "multiple relays for" in str(ctx.exception)
@@ -279,7 +279,7 @@ class OnionOOTests(unittest.TestCase):
         agent.request = Mock(return_value=defer.succeed(resp))
 
         with self.assertRaises(Exception) as ctx:
-            data = yield self.router.get_onionoo_details(agent)
+            yield self.router.get_onionoo_details(agent)
 
         self.assertTrue(
             " but got data for " in str(ctx.exception)
diff --git a/test/test_torcontrolprotocol.py b/test/test_torcontrolprotocol.py
index a3beda5..03465f0 100644
--- a/test/test_torcontrolprotocol.py
+++ b/test/test_torcontrolprotocol.py
@@ -849,6 +849,40 @@ platform Tor 0.2.5.0-alpha-dev on Linux
         self.send(b"650 STREAM 2345 NEW 4321 2.3.4.5:666 REASON=MISC")
         self.assertEqual(listener.stream_events, 2)
 
+    def test_eventlistener_error(self):
+        self.protocol._set_valid_events('STREAM')
+
+        class EventListener(object):
+            stream_events = 0
+            do_error = False
+
+            def __call__(self, data):
+                self.stream_events += 1
+                if self.do_error:
+                    raise Exception("the bad thing happened")
+
+        # we make sure the first listener has the errors to prove the
+        # second one still gets called.
+        listener0 = EventListener()
+        listener0.do_error = True
+        listener1 = EventListener()
+        self.protocol.add_event_listener('STREAM', listener0)
+        self.protocol.add_event_listener('STREAM', listener1)
+
+        d = self.protocol.defer
+        self.send(b"250 OK")
+        self._wait(d)
+        self.send(b"650 STREAM 1234 NEW 4321 1.2.3.4:555 REASON=MISC")
+        self.send(b"650 STREAM 2345 NEW 4321 2.3.4.5:666 REASON=MISC")
+        self.assertEqual(listener0.stream_events, 2)
+        self.assertEqual(listener1.stream_events, 2)
+
+        # should have logged the two errors
+        logged = self.flushLoggedErrors()
+        self.assertEqual(2, len(logged))
+        self.assertTrue("the bad thing happened" in str(logged[0]))
+        self.assertTrue("the bad thing happened" in str(logged[1]))
+
     def test_remove_eventlistener(self):
         self.protocol._set_valid_events('STREAM')
 
@@ -900,13 +934,12 @@ platform Tor 0.2.5.0-alpha-dev on Linux
         except Exception as e:
             self.assertTrue('FOO' in str(e))
 
-    def checkContinuation(self, v):
-        self.assertEqual(v, "key=\nvalue0\nvalue1")
-
-    def test_continuationLine(self):
+    def test_continuation_line(self):
         d = self.protocol.get_info_raw("key")
 
-        d.addCallback(self.checkContinuation)
+        def check_continuation(v):
+            self.assertEqual(v, "key=\nvalue0\nvalue1")
+        d.addCallback(check_continuation)
 
         self.send(b"250+key=")
         self.send(b"value0")

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
apt-get update apt-get install -y gcc libgeoip-dev
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.16
ansicolors==1.1.8
attrs==25.3.0
Automat==24.8.1
babel==2.17.0
backports.tarfile==1.2.0
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.4.1
click==8.1.8
codecov==2.1.13
colorama==0.4.6
constantly==23.10.4
coverage==7.8.0
coveralls==4.0.1
cryptography==44.0.2
cuvner==24.12.1
distlib==0.3.9
docopt==0.6.2
docutils==0.21.2
exceptiongroup==1.2.2
execnet==2.1.1
filelock==3.18.0
GeoIP==1.3.2
hyperlink==21.0.0
id==1.5.0
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
incremental==24.7.2
iniconfig==2.1.0
ipaddress==1.0.23
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
jeepney==0.9.0
Jinja2==3.1.6
keyring==25.6.0
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
mock==5.2.0
more-itertools==10.6.0
nh3==0.2.21
packaging==24.2
pep8==1.7.1
platformdirs==4.3.7
pluggy==1.5.0
pyasn1==0.6.1
pyasn1_modules==0.4.2
pycparser==2.22
pyflakes==3.3.1
Pygments==2.19.1
pyOpenSSL==25.0.0
pyproject-api==1.9.0
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
readme_renderer==44.0
repoze.sphinx.autointerface==1.0.0
requests==2.32.3
requests-toolbelt==1.0.0
rfc3986==2.0.0
rich==14.0.0
SecretStorage==3.3.3
service-identity==24.2.0
six==1.17.0
snowballstemmer==2.2.0
Sphinx==7.4.7
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
tomli==2.2.1
tox==4.25.0
twine==6.1.0
Twisted==24.11.0
-e git+https://github.com/meejah/txtorcon.git@8139ebb8f48544121274aaa2892117f02862dc5f#egg=txtorcon
typing_extensions==4.13.0
unidiff==0.7.5
urllib3==2.3.0
virtualenv==20.29.3
watchdog==6.0.0
zipp==3.21.0
zope.interface==7.2

name: txtorcon
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.16
      - ansicolors==1.1.8
      - attrs==25.3.0
      - automat==24.8.1
      - babel==2.17.0
      - backports-tarfile==1.2.0
      - cachetools==5.5.2
      - certifi==2025.1.31
      - cffi==1.17.1
      - chardet==5.2.0
      - charset-normalizer==3.4.1
      - click==8.1.8
      - codecov==2.1.13
      - colorama==0.4.6
      - constantly==23.10.4
      - coverage==7.8.0
      - coveralls==4.0.1
      - cryptography==44.0.2
      - cuvner==24.12.1
      - distlib==0.3.9
      - docopt==0.6.2
      - docutils==0.21.2
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - filelock==3.18.0
      - geoip==1.3.2
      - hyperlink==21.0.0
      - id==1.5.0
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==8.6.1
      - incremental==24.7.2
      - iniconfig==2.1.0
      - ipaddress==1.0.23
      - jaraco-classes==3.4.0
      - jaraco-context==6.0.1
      - jaraco-functools==4.1.0
      - jeepney==0.9.0
      - jinja2==3.1.6
      - keyring==25.6.0
      - markdown-it-py==3.0.0
      - markupsafe==3.0.2
      - mdurl==0.1.2
      - mock==5.2.0
      - more-itertools==10.6.0
      - nh3==0.2.21
      - packaging==24.2
      - pep8==1.7.1
      - platformdirs==4.3.7
      - pluggy==1.5.0
      - pyasn1==0.6.1
      - pyasn1-modules==0.4.2
      - pycparser==2.22
      - pyflakes==3.3.1
      - pygments==2.19.1
      - pyopenssl==25.0.0
      - pyproject-api==1.9.0
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - pytest-xdist==3.6.1
      - readme-renderer==44.0
      - repoze-sphinx-autointerface==1.0.0
      - requests==2.32.3
      - requests-toolbelt==1.0.0
      - rfc3986==2.0.0
      - rich==14.0.0
      - secretstorage==3.3.3
      - service-identity==24.2.0
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==7.4.7
      - sphinxcontrib-applehelp==2.0.0
      - sphinxcontrib-devhelp==2.0.0
      - sphinxcontrib-htmlhelp==2.1.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==2.0.0
      - sphinxcontrib-serializinghtml==2.0.0
      - tomli==2.2.1
      - tox==4.25.0
      - twine==6.1.0
      - twisted==24.11.0
      - typing-extensions==4.13.0
      - unidiff==0.7.5
      - urllib3==2.3.0
      - virtualenv==20.29.3
      - watchdog==6.0.0
      - zipp==3.21.0
      - zope-interface==7.2
prefix: /opt/conda/envs/txtorcon

test/test_torcontrolprotocol.py::ProtocolTests::test_eventlistener_error
test/test_router.py::UtilityTests::test_hex_converters test/test_router.py::RouterTests::test_countrycode test/test_router.py::RouterTests::test_ctor test/test_router.py::RouterTests::test_flags test/test_router.py::RouterTests::test_flags_from_string test/test_router.py::RouterTests::test_policy_accept test/test_router.py::RouterTests::test_policy_error test/test_router.py::RouterTests::test_policy_not_set_error test/test_router.py::RouterTests::test_policy_reject test/test_router.py::RouterTests::test_repr test/test_router.py::RouterTests::test_repr_no_update test/test_router.py::RouterTests::test_unique_name test/test_router.py::OnionOOTests::test_onionoo_get_fails test/test_router.py::OnionOOTests::test_onionoo_success test/test_router.py::OnionOOTests::test_onionoo_too_many_answers test/test_router.py::OnionOOTests::test_onionoo_wrong_fingerprint test/test_torcontrolprotocol.py::InterfaceTests::test_implements test/test_torcontrolprotocol.py::InterfaceTests::test_object_implements test/test_torcontrolprotocol.py::LogicTests::test_set_conf_wrong_args test/test_torcontrolprotocol.py::FactoryTests::test_create test/test_torcontrolprotocol.py::AuthenticationTests::test_authenticate_cookie test/test_torcontrolprotocol.py::AuthenticationTests::test_authenticate_no_password test/test_torcontrolprotocol.py::AuthenticationTests::test_authenticate_null test/test_torcontrolprotocol.py::AuthenticationTests::test_authenticate_password test/test_torcontrolprotocol.py::AuthenticationTests::test_authenticate_password_deferred test/test_torcontrolprotocol.py::AuthenticationTests::test_authenticate_password_deferred_but_no_password test/test_torcontrolprotocol.py::AuthenticationTests::test_authenticate_password_not_bytes test/test_torcontrolprotocol.py::DisconnectionTests::test_disconnect_callback test/test_torcontrolprotocol.py::DisconnectionTests::test_disconnect_errback test/test_torcontrolprotocol.py::ProtocolTests::test_650_after_authenticate test/test_torcontrolprotocol.py::ProtocolTests::test_addevent test/test_torcontrolprotocol.py::ProtocolTests::test_async test/test_torcontrolprotocol.py::ProtocolTests::test_async_multiline test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_cookie_without_reading test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_dont_send_cookiefile test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_fail test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_no_auth_line test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_not_enough_cookie_data test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_not_enough_safecookie_data test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_password_when_cookie_unavailable test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_password_when_safecookie_unavailable test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_safecookie test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_safecookie_wrong_hash test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_unexisting_cookie_file test/test_torcontrolprotocol.py::ProtocolTests::test_authenticate_unexisting_safecookie_file test/test_torcontrolprotocol.py::ProtocolTests::test_bootstrap_callback test/test_torcontrolprotocol.py::ProtocolTests::test_bootstrap_tor_does_not_support_signal_names test/test_torcontrolprotocol.py::ProtocolTests::test_continuation_line test/test_torcontrolprotocol.py::ProtocolTests::test_debug test/test_torcontrolprotocol.py::ProtocolTests::test_dot test/test_torcontrolprotocol.py::ProtocolTests::test_eventlistener test/test_torcontrolprotocol.py::ProtocolTests::test_getconf test/test_torcontrolprotocol.py::ProtocolTests::test_getconf_raw test/test_torcontrolprotocol.py::ProtocolTests::test_getinfo test/test_torcontrolprotocol.py::ProtocolTests::test_getinfo_for_descriptor test/test_torcontrolprotocol.py::ProtocolTests::test_getinfo_incremental test/test_torcontrolprotocol.py::ProtocolTests::test_getinfo_incremental_continuation test/test_torcontrolprotocol.py::ProtocolTests::test_getinfo_multiline test/test_torcontrolprotocol.py::ProtocolTests::test_getinfo_one_line test/test_torcontrolprotocol.py::ProtocolTests::test_minus_line_no_command test/test_torcontrolprotocol.py::ProtocolTests::test_multiline_plus test/test_torcontrolprotocol.py::ProtocolTests::test_multiline_plus_embedded_equals test/test_torcontrolprotocol.py::ProtocolTests::test_newdesc test/test_torcontrolprotocol.py::ProtocolTests::test_notify_after_getinfo test/test_torcontrolprotocol.py::ProtocolTests::test_notify_error test/test_torcontrolprotocol.py::ProtocolTests::test_plus_line_no_command test/test_torcontrolprotocol.py::ProtocolTests::test_quit test/test_torcontrolprotocol.py::ProtocolTests::test_remove_eventlistener test/test_torcontrolprotocol.py::ProtocolTests::test_remove_eventlistener_multiple test/test_torcontrolprotocol.py::ProtocolTests::test_response_with_no_request test/test_torcontrolprotocol.py::ProtocolTests::test_setconf test/test_torcontrolprotocol.py::ProtocolTests::test_setconf_multi test/test_torcontrolprotocol.py::ProtocolTests::test_setconf_with_space test/test_torcontrolprotocol.py::ProtocolTests::test_signal test/test_torcontrolprotocol.py::ProtocolTests::test_signal_error test/test_torcontrolprotocol.py::ProtocolTests::test_statemachine_broadcast_no_code test/test_torcontrolprotocol.py::ProtocolTests::test_statemachine_broadcast_unknown_code test/test_torcontrolprotocol.py::ProtocolTests::test_statemachine_continuation test/test_torcontrolprotocol.py::ProtocolTests::test_statemachine_is_finish test/test_torcontrolprotocol.py::ProtocolTests::test_statemachine_multiline test/test_torcontrolprotocol.py::ProtocolTests::test_statemachine_singleline test/test_torcontrolprotocol.py::ProtocolTests::test_twocommands test/test_torcontrolprotocol.py::ParseTests::test_circuit_status test/test_torcontrolprotocol.py::ParseTests::test_default_keywords test/test_torcontrolprotocol.py::ParseTests::test_keywords test/test_torcontrolprotocol.py::ParseTests::test_keywords_mutli_equals test/test_torcontrolprotocol.py::ParseTests::test_multientry_keywords_2 test/test_torcontrolprotocol.py::ParseTests::test_multientry_keywords_3 test/test_torcontrolprotocol.py::ParseTests::test_multientry_keywords_4 test/test_torcontrolprotocol.py::ParseTests::test_multiline_keywords test/test_torcontrolprotocol.py::ParseTests::test_multiline_keywords_with_spaces test/test_torcontrolprotocol.py::ParseTests::test_network_status test/test_torcontrolprotocol.py::ParseTests::test_unquoted_keywords test/test_torcontrolprotocol.py::ParseTests::test_unquoted_keywords_empty test/test_torcontrolprotocol.py::ParseTests::test_unquoted_keywords_singlequote
txtorcon/router.py txtorcon/torcontrolprotocol.py
txtorcon/router.py txtorcon/torcontrolprotocol.py