From ac9d8f194d2cfa2e6c4280ee4f2f9e41f674c937 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Fri, 11 Sep 2009 12:08:02 +0000 Subject: [PATCH] * morituri/common/task.py: Make SyncRunner wrap start() so we correctly handle any exception being thrown. --- ChangeLog | 6 ++++++ morituri/common/task.py | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c2d6295..335653e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-09-11 Thomas Vander Stichele + + * morituri/common/task.py: + Make SyncRunner wrap start() so we correctly handle any + exception being thrown. + 2009-09-11 Thomas Vander Stichele * morituri/common/checksum.py: diff --git a/morituri/common/task.py b/morituri/common/task.py index d884e0a..2f233d7 100644 --- a/morituri/common/task.py +++ b/morituri/common/task.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)