def is_waiting_to_run(self):
        if self.status != self.WAITING:
            LOG.info("Migration: {} has already run!".format(self))
            return False

        inspect = control.inspect()
        scheduled_tasks = inspect.scheduled()
        try:
            hosts = scheduled_tasks.keys()
        except Exception as e:
            LOG.info("Could not retrieve celery scheduled tasks: {}".format(e))
            return False

        for host in hosts:
            try:
                scheduled_tasks = scheduled_tasks[host]
            except __HOLE__:
                LOG.warn("There are no scheduled tasks")
                LOG.info(scheduled_tasks)
                continue

            for task in scheduled_tasks:
                if task['request']['id'] == self.celery_task_id:
                    return True

        return False
dataset/ETHPy150Open globocom/database-as-a-service/dbaas/region_migration/models.py/DatabaseRegionMigrationDetail.is_waiting_to_run