+ @type tasks: list of tuples
+ @param tasks: list of args passed to L{BaseWorker.RunTask}
+ @type priority: number or list of numbers
+ @param priority: Priority for all added tasks or a list with the priority
+ for each task
+ @type task_id: list
+ @param task_id: List with the ID for each task
+ @note: See L{AddTask} for a note on task IDs.
+
+ """
+ assert compat.all(isinstance(task, (tuple, list)) for task in tasks), \
+ "Each task must be a sequence"
+ assert (isinstance(priority, (int, long)) or
+ compat.all(isinstance(prio, (int, long)) for prio in priority)), \
+ "Priority must be numeric or be a list of numeric values"
+ assert task_id is None or isinstance(task_id, (tuple, list)), \
+ "Task IDs must be in a sequence"
+
+ if isinstance(priority, (int, long)):
+ priority = [priority] * len(tasks)
+ elif len(priority) != len(tasks):
+ raise errors.ProgrammerError("Number of priorities (%s) doesn't match"
+ " number of tasks (%s)" %
+ (len(priority), len(tasks)))
+
+ if task_id is None:
+ task_id = [None] * len(tasks)
+ elif len(task_id) != len(tasks):
+ raise errors.ProgrammerError("Number of task IDs (%s) doesn't match"
+ " number of tasks (%s)" %
+ (len(task_id), len(tasks)))
+
+ self._lock.acquire()
+ try:
+ self._WaitWhileQuiescingUnlocked()
+
+ assert compat.all(isinstance(prio, (int, long)) for prio in priority)
+ assert len(tasks) == len(priority)
+ assert len(tasks) == len(task_id)
+
+ for (args, prio, tid) in zip(tasks, priority, task_id):
+ self._AddTaskUnlocked(args, prio, tid)