def METHOD_NAME(self, task, method):
    with self._lock:
        if task.id in self._tasks:
            raise se.AddTaskError(
                'Task id already in use: {0}'.format(task.id))
        self.log.debug("queuing task: %s", task.id)
        self._tasks[task.id] = task
    try:
        if not self.tp.queueTask(task.id, method):
            self.log.error("unable to queue task: %s", task.dumpTask())
            with self._lock:
                del self._tasks[task.id]
            raise se.AddTaskError()
        self.log.debug("task queued: %s", task.id)
    except Exception:
        self.log.exception('could not queue task %s', task.id)
        raise
    return task.id