From b540b10c331c592714406d6d59b0cda5cdf9e031 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Tue, 24 May 2011 13:21:51 +0000 Subject: [PATCH] * morituri/common/task.py: More exception handling and debug. --- ChangeLog | 13 +++++++++++++ morituri/common/task.py | 10 ++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98ecad6..b9fb218 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-05-24 Thomas Vander Stichele + + * morituri/common/task.py: + More exception handling and debug. + 2011-05-24 Thomas Vander Stichele * morituri/common/task.py: @@ -10,6 +15,14 @@ * morituri/program/cdrdao.py: Adapt. +2011-05-24 Thomas Vander Stichele + + reviewed by: + patch by: + + * morituri/common/gstreamer.py: + * morituri/image/image.py: + 2011-05-24 Thomas Vander Stichele * morituri/test/test_common_encode.py: diff --git a/morituri/common/task.py b/morituri/common/task.py index 8dd68d8..658eb34 100644 --- a/morituri/common/task.py +++ b/morituri/common/task.py @@ -173,7 +173,11 @@ class Task(object, log.Loggable): def _notifyListeners(self, methodName, *args, **kwargs): if self._listeners: for l in self._listeners: - getattr(l, methodName)(self, *args, **kwargs) + method = getattr(l, methodName) + try: + method(self, *args, **kwargs) + except Exception, e: + self.setException(e) # FIXME: should this become a real interface, like in zope ? class ITaskListener(object): @@ -298,7 +302,8 @@ class BaseMultiTask(Task, ITaskListener): Subclasses should chain up to me at the end of their implementation. They should fall through to chaining up if there is an exception. """ - self.log('BaseMultiTask.stopped: task %r', task) + self.log('BaseMultiTask.stopped: task %r (%d of %d)', + task, self.tasks.index(task) + 1, len(self.tasks)) if task.exception: self.log('BaseMultiTask.stopped: exception %r', task.exceptionMessage) @@ -446,6 +451,7 @@ class SyncRunner(TaskRunner, ITaskListener): self.debug('exception when calling scheduled callable %r', callable) task.setException(e) + self.stopped(task) raise gobject.timeout_add(int(delta * 1000L), c)