def duplicate_task(self, tid): """Duplicate the task with ID 'tid'.""" t = self.tasks[tid] if t.core >= 0: raise Exception("Running tasks cannot be duplicated.") self.task_count += 1 task_id = "T%04d" % self.task_count d = Task( task_id, -1, t.pname, t.program, dummy_mode=t.dummy_mode, status=t._status ) d.output = t.output self.tasks[task_id] = d