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
def get_task(self, tid): if tid not in self.tasks: log.debug("Missing task %s, checking filesystem.", tid) task = Task.unpickle(tid, self.work_dir) self._enqueue(task) return self.tasks[tid]
def test_unpickle_missing(tmpdir): with pytest.raises(NoSuchTaskError): Task.unpickle('asdf', str(tmpdir))
def test_task_pickle_unpickle_id(tmpdir, idtask): tid = idtask.pickle(str(tmpdir)) tsk = Task.unpickle(tid, str(tmpdir)) assert 1 == len(tmpdir.listdir()) assert tid == tsk.tid assert '' == tsk.run()