From: Ed Page Date: Tue, 20 Apr 2010 02:27:52 +0000 (-0500) Subject: Enabling logging to raise exceptions, hardening my exception handling, and tracking... X-Git-Url: http://vcs.maemo.org/git/?p=theonering;a=commitdiff_plain;h=7893a8142f7f82473964cb6cb76696d9fe3ed11d Enabling logging to raise exceptions, hardening my exception handling, and tracking when the worker thread finally dies --- diff --git a/src/channel/call.py b/src/channel/call.py index 0fd08ea..aefc598 100644 --- a/src/channel/call.py +++ b/src/channel/call.py @@ -186,7 +186,7 @@ class CallChannel( {}, ) except Exception: - _moduleLogger.exception(result) + _moduleLogger.exception("While placing call to %s" % (self.__calledNumber, )) return self._delayedClose.start(seconds=0) @@ -202,7 +202,7 @@ class CallChannel( {}, ) except Exception: - _moduleLogger.exception(result) + _moduleLogger.exception("While canceling a call to %s" % (self.__calledNumber, )) return @misc_utils.log_exception(_moduleLogger) diff --git a/src/channel/debug_prompt.py b/src/channel/debug_prompt.py index 47a31dd..545f952 100644 --- a/src/channel/debug_prompt.py +++ b/src/channel/debug_prompt.py @@ -166,6 +166,7 @@ class DebugPromptChannel(tp.ChannelTypeText, cmd.Cmd): self._report_new_message(str(isAuthed)) except Exception, e: self._report_new_message(str(e)) + return def help_is_authed(self): self._report_new_message("Print whether logged in to Google Voice") @@ -189,6 +190,7 @@ class DebugPromptChannel(tp.ChannelTypeText, cmd.Cmd): self._report_new_message(str(isDnd)) except Exception, e: self._report_new_message(str(e)) + return def help_is_dnd(self): self._report_new_message("Print whether Do-Not-Disturb mode enabled on the Google Voice account") diff --git a/src/connection.py b/src/connection.py index 96808cb..4ade96e 100644 --- a/src/connection.py +++ b/src/connection.py @@ -235,7 +235,9 @@ class TheOneRingConnection( @misc_utils.log_exception(_moduleLogger) def _on_login_error(self, error): _moduleLogger.error(error) - if isinstance(error, gvoice.backend.NetworkError): + if isinstance(error, StopIteration): + pass + elif isinstance(error, gvoice.backend.NetworkError): self.disconnect(telepathy.CONNECTION_STATUS_REASON_NETWORK_ERROR) else: self.disconnect(telepathy.CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED) diff --git a/src/gvoice/addressbook.py b/src/gvoice/addressbook.py index 2a5e389..9d241cf 100644 --- a/src/gvoice/addressbook.py +++ b/src/gvoice/addressbook.py @@ -32,11 +32,15 @@ class Addressbook(object): @misc_utils.log_exception(_moduleLogger) def _update(self): - contacts = yield ( - self._backend.get_contacts, - (), - {}, - ) + try: + contacts = yield ( + self._backend.get_contacts, + (), + {}, + ) + except Exception: + _moduleLogger.exception("While updating the addressbook") + return oldContacts = self._numbers oldContactNumbers = set(self.get_numbers()) diff --git a/src/gvoice/conversations.py b/src/gvoice/conversations.py index 2b7df61..b48887e 100644 --- a/src/gvoice/conversations.py +++ b/src/gvoice/conversations.py @@ -96,11 +96,15 @@ class Conversations(object): @misc_utils.log_exception(_moduleLogger) def _update(self): - conversationResult = yield ( - self._get_raw_conversations, - (), - {}, - ) + try: + conversationResult = yield ( + self._get_raw_conversations, + (), + {}, + ) + except Exception: + _moduleLogger.exception("%s While updating conversations" % (self._name, )) + return oldConversationIds = set(self._conversations.iterkeys()) diff --git a/src/theonering.py b/src/theonering.py index 49a173f..bc8a6cf 100755 --- a/src/theonering.py +++ b/src/theonering.py @@ -91,6 +91,7 @@ def main(logToFile): telepathy_utils.debug_divert_messages(os.getenv('THEONERING_LOGFILE')) logFormat = '(%(asctime)s) %(levelname)-5s %(threadName)s.%(name)s: %(message)s' + logging.raiseExceptions = True # Getting funky shutdown behavior, checking it out if logToFile: logging.basicConfig( level=logging.DEBUG, diff --git a/src/util/go_utils.py b/src/util/go_utils.py index 52ccf92..20ccac1 100644 --- a/src/util/go_utils.py +++ b/src/util/go_utils.py @@ -169,7 +169,6 @@ class AsyncPool(object): callback(result) except Exception: _moduleLogger.exception("Callback errored") - pass return False @misc.log_exception(_moduleLogger) @@ -190,6 +189,7 @@ class AsyncPool(object): self.__workQueue.task_done() gobject.idle_add(self.__trampoline_callback, on_success, on_error, isError, result) + _moduleLogger.debug("Shutting down worker thread") class AsyncLinearExecution(object):