'Wait for all queued jobs to be completed, if timeout is not None,
will raise a RuntimeError if jobs are not completed in the specified
time. Will raise a :class:`Failure` exception if a terminal failure has
occurred previously.'

def wait_for_tasks(self, timeout=None):

    if self.failed:
        raise Failure(self.terminal_failure)
    if (timeout is None):
        self.tracker.join()
    else:
        join_with_timeout(self.tracker, timeout)
