[SCM] morituri/master: * morituri/common/task.py: Make SyncRunner wrap start() so we correctly handle any exception being thrown.

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:09:11 UTC 2014


The following commit has been merged in the master branch:
commit ac9d8f194d2cfa2e6c4280ee4f2f9e41f674c937
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Fri Sep 11 12:08:02 2009 +0000

    	* morituri/common/task.py:
    	  Make SyncRunner wrap start() so we correctly handle any
    	  exception being thrown.

diff --git a/ChangeLog b/ChangeLog
index c2d6295..335653e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 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:
 	* morituri/test/Makefile.am:
 	* morituri/test/test_common_checksum.py (added):
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)

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list