def end(self, synchronous=False):
    if synchronous:
        while any([(task.state not in celery_states.READY_STATES) for task in self.tasks.values()]):
            time.sleep(5)
    self.sync()
def end(self, synchronous=False):
    if synchronous:
        while any([(task.state not in celery_states.READY_STATES) for task in self.tasks.values()]):
            time.sleep(5)
    self.sync()