diff --git a/cassandra/io/asyncorereactor.py b/cassandra/io/asyncorereactor.py index 0aca79e6..02b78d53 100644 --- a/cassandra/io/asyncorereactor.py +++ b/cassandra/io/asyncorereactor.py @@ -204,7 +204,12 @@ class AsyncoreConnection(Connection, asyncore.dispatcher): def _error_all_callbacks(self, exc): new_exc = ConnectionShutdown(str(exc)) for cb in self._callbacks.values(): - cb(new_exc) + try: + cb(new_exc) + except Exception: + log.warn("Ignoring unhandled exception while erroring callbacks for a " + "failed connection (%s) to host %s:", + id(self), self.host, exc_info=True) def handle_connect(self): with _starting_conns_lock: diff --git a/cassandra/io/libevreactor.py b/cassandra/io/libevreactor.py index 792cdb48..0db6e298 100644 --- a/cassandra/io/libevreactor.py +++ b/cassandra/io/libevreactor.py @@ -183,7 +183,12 @@ class LibevConnection(Connection): def _error_all_callbacks(self, exc): new_exc = ConnectionShutdown(str(exc)) for cb in self._callbacks.values(): - cb(new_exc) + try: + cb(new_exc) + except Exception: + log.warn("Ignoring unhandled exception while erroring callbacks for a " + "failed connection (%s) to host %s:", + id(self), self.host, exc_info=True) def handle_write(self, watcher, revents): try: