def __init__(self, func, arg, uniq=None, background=False, high_priority=False, timeout=None, retry_count=0): Task.__init__(self, func, arg, uniq, background, high_priority, timeout, retry_count)
def dispatch_background_task(self, func, arg, uniq=None, high_priority=False): """Submit a background task and return its handle.""" task = Task(func, arg, uniq, background=True, high_priority=high_priority) taskset = Taskset([task]) self.do_taskset(taskset) return task.handle
def testTimeout(self): self.failUnlessEqual(self.client.do_task(Task("sleep", "0.1")), '0.1') self.failUnlessRaises(self.client.TaskFailed, lambda:self.client.do_task(Task("sleep", "1.5")))
def testCompleteAfterFail(self): self.failUnlessRaises(self.client.TaskFailed, lambda:self.client.do_task(Task("fail", "bar"))) self.failUnlessEqual(self.client.do_task(Task("echo", "bar")), 'bar')
def testFail(self): self.failUnlessRaises(self.client.TaskFailed, lambda:self.client.do_task(Task("fail", "bar")))
def testComplete(self): self.failUnlessEqual(self.client.do_task(Task("echo", "bar")), 'bar')
def __init__(self,func,arg,uniq=None,background=False,high_priority=False,timeout=None,retry_count=0): Task.__init__(self,func,arg,uniq,background,high_priority,timeout,retry_count)
def __call__(self, func, arg, uniq=None, **kwargs): return self.do_task(Task(func, arg, uniq, **kwargs))