Handle exceptions when erroring callbacks
In case any of the callbacks don't properly handle exceptions, handle the exceptions (with a log message) and continue erroring out the rest of the callbacks. Related to #48
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user