'Wait for task and return its result.
If the task raises an exception, this exception
will be re-raised by :func:`wait_for`.
Raises:
celery.exceptions.TimeoutError:
If `timeout` is not :const:`None`, and the operation
takes longer than `timeout` seconds.'

def wait_for(self, task_id, timeout=None, interval=0.5, no_ack=True, on_interval=None):

    self._ensure_not_eager()
    time_elapsed = 0.0
    while 1:
        meta = self.get_task_meta(task_id)
        if (meta[u'status'] in states.READY_STATES):
            return meta
        if on_interval:
            on_interval()
        time.sleep(interval)
        time_elapsed += interval
        if (timeout and (time_elapsed >= timeout)):
            raise TimeoutError(u'The    operation    timed    out.')
