* morituri/common/task.py:
Make SyncRunner wrap start() so we correctly handle any exception being thrown.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user