From 4d4c6404b152396b3d531f130d8318c1b41a2c92 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 28 May 2011 16:27:26 +0100 Subject: [PATCH] Log exception occurring while sending RPC errors to clients. --- deluge/core/rpcserver.py | 22 ++++++++++++++-------- deluge/core/torrent.py | 6 +++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/deluge/core/rpcserver.py b/deluge/core/rpcserver.py index 24c894dbb..d176ff01b 100644 --- a/deluge/core/rpcserver.py +++ b/deluge/core/rpcserver.py @@ -246,14 +246,20 @@ class DelugeRPCProtocol(Protocol): Sends an error response with the contents of the exception that was raised. """ exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() - self.sendData(( - RPC_ERROR, - request_id, - exceptionType.__name__, - exceptionValue._args, - exceptionValue._kwargs, - "".join(traceback.format_tb(exceptionTraceback)) - )) + try: + self.sendData(( + RPC_ERROR, + request_id, + exceptionType.__name__, + exceptionValue._args, + exceptionValue._kwargs, + "".join(traceback.format_tb(exceptionTraceback)) + )) + except Exception, err: + log.error("An exception occurred while sending RPC_ERROR to " + "client. Error to send(exception goes next): %s", + "".join(traceback.format_tb(exceptionTraceback))) + log.exception(err) if method == "daemon.info": # This is a special case and used in the initial connection process diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 723b7c583..0b32d545a 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -189,14 +189,14 @@ class Torrent(object): else: self.owner = owner - # Keep trac of last seen complete + # Keep track of last seen complete if state: self._last_seen_complete = state.last_seen_complete or 0.0 else: self._last_seen_complete = 0.0 # Keep track if we're forcing a recheck of the torrent so that we can - # repause it after its done if necessary + # re-pause it after its done if necessary self.forcing_recheck = False self.forcing_recheck_paused = False @@ -359,7 +359,7 @@ class Torrent(object): # Set the tracker list in the torrent object self.trackers = trackers if len(trackers) > 0: - # Force a reannounce if there is at least 1 tracker + # Force a re-announce if there is at least 1 tracker self.force_reannounce() self.tracker_host = None