* morituri/common/task.py:

Make SyncRunner wrap start() so we correctly handle any
	  exception being thrown.
This commit is contained in:
Thomas Vander Stichele
2009-09-11 12:08:02 +00:00
parent d9530cb82a
commit ac9d8f194d
2 changed files with 17 additions and 1 deletions

View File

@@ -1,3 +1,9 @@
2009-09-11 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/task.py:
Make SyncRunner wrap start() so we correctly handle any
exception being thrown.
2009-09-11 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/checksum.py:

View File

@@ -339,7 +339,7 @@ class SyncRunner(TaskRunner, ITaskListener):
self._task.addListener(self)
# only start the task after going into the mainloop,
# otherwise the task might complete before we are in it
gobject.timeout_add(0L, self._task.start, self)
gobject.timeout_add(0L, self._startWrap, self._task)
self._loop.run()
self.debug('done running task %r', task)
@@ -349,6 +349,16 @@ class SyncRunner(TaskRunner, ITaskListener):
# log.getExceptionMessage(self._task.exception))
raise task.exception
def _startWrap(self, task):
# wrap task start such that we can report any exceptions and
# never hang
try:
task.start(self)
except Exception, e:
task.exception = e
self.stopped(task)
def schedule(self, delta, callable, *args, **kwargs):
def c():
callable(*args, **kwargs)