def test_pickle_with_badid(tmpdir): tsk = Task(str, tid="/tmp/foobar") tsk.pickle(str(tmpdir)) assert 1 == len(tmpdir.listdir()) assert tmpdir.listdir()[0].isfile() utsk = Task.unpickle(tsk.tid, str(tmpdir)) assert utsk.tid == tsk.tid
def enqueue(self, fn, tid=None, after=None): if tid: if tid in self.tasks: return tid if after: after = filter(None, after) # check that all tasks specified exist or raise the # exception now if one of them doesn't. an effect this # enforces is that everything must be queued into the pool # before this task is to prevent deadlock map(self.get_task, after) task = Task(fn, tid=tid, after=after) task.pickle(self.work_dir) self._enqueue(task) return task.tid