diff --git a/resources/lib/backgroundthread.py b/resources/lib/backgroundthread.py index 45c14f87..055f66ef 100644 --- a/resources/lib/backgroundthread.py +++ b/resources/lib/backgroundthread.py @@ -160,6 +160,17 @@ class Task(object): return not self.finished and not self._canceled +def FunctionAsTask(Task): + def __init__(self, function, *args, **kwargs): + self.function = function + self._args = args + self._kwargs = kwargs + super(FunctionAsTask, self).__init__() + + def run(self): + self.function(*self._args, **self._kwargs) + + class MutablePriorityQueue(Queue.PriorityQueue): def _get(self, heappop=heapq.heappop): self.queue.sort()