@staticmethod
    def wait_for_instances(instances, timeout=None, callback=None):
        t0 = time.time()
        while any(i.state == 'pending' for i in instances):
            if timeout and time.time() > t0 + timeout:
                raise TimeoutError(
                    "Timed out waiting for instances to start: " + [i.id for i in instances]
                    )
            time.sleep(1)
            status = {}
            for i in instances:
                if not i.state in status:
                    status[i.state] = []
                status[i.state].append(i.id)

                if i.state == 'pending':
                    i.update()
            if callback:
                callback(status)
        return True
dataset/ETHPy150Open ufora/ufora/packages/python/pyfora/aws/Launcher.py/Launcher.wait_for_instances/original