* morituri/common/task.py:

add task argument to TaskRunner.schedule so we can get exceptions.
	  Add .schedule method to Task to pass self.
	* morituri/common/checksum.py:
	* morituri/common/encode.py:
	* morituri/common/gstreamer.py:
	* morituri/program/cdparanoia.py:
	* morituri/program/cdrdao.py:
	  Adapt.
This commit is contained in:
Thomas Vander Stichele
2011-05-24 12:51:40 +00:00
parent 4454abcc85
commit 8bc5eff73c
7 changed files with 44 additions and 22 deletions

View File

@@ -155,6 +155,10 @@ class Task(object, log.Loggable):
self.debug('set exception, %r, %r' % (
exception, self.exceptionMessage))
def schedule(self, delta, callable, *args, **kwargs):
self.runner.schedule(self, delta, callable, *args, **kwargs)
def addListener(self, listener):
"""
Add a listener for task status changes.
@@ -210,7 +214,7 @@ class ITaskListener(object):
class DummyTask(Task):
def start(self, runner):
Task.start(self, runner)
self.runner.schedule(1.0, self._wind)
self.schedule(1.0, self._wind)
def _wind(self):
self.setProgress(min(self.progress + 0.1, 1.0))
@@ -219,7 +223,7 @@ class DummyTask(Task):
self.stop()
return
self.runner.schedule(1.0, self._wind)
self.schedule(1.0, self._wind)
class BaseMultiTask(Task, ITaskListener):
"""
@@ -433,10 +437,16 @@ class SyncRunner(TaskRunner, ITaskListener):
self.stopped(task)
def schedule(self, delta, callable, *args, **kwargs):
def schedule(self, task, delta, callable, *args, **kwargs):
def c():
callable(*args, **kwargs)
return False
try:
callable(*args, **kwargs)
return False
except Exception, e:
self.debug('exception when calling scheduled callable %r',
callable)
task.setException(e)
raise
gobject.timeout_add(int(delta * 1000L), c)
### ITaskListener methods