def wait_for_services(self, instances, callback=None):
        assert self.connected
        pending = set(instances)
        ready = []
        failed = []

        while len(pending):
            toRemove = []
            for i in pending:
                i.update()
                if 'status' not in i.tags:
                    continue

                if i.tags['status'].endswith('failed'):
                    toRemove.append(i)
                    failed.append(i)
                elif i.tags['status'] == 'ready':
                    toRemove.append(i)
                    ready.append(i)

            for i in toRemove:
                pending.remove(i)

            status = {}
            for i in itertools.chain(pending, ready, failed):
                if 'status' not in i.tags:
                    # there is no status while the instance installs the AWS cli
                    status_name = 'installing dependencies'
                else:
                    status_name = i.tags['status']

                if status not in status_name:
                    status[status_name] = []
                status[status_name].append(i)
            if callback:
                callback(status)

            if len(pending):
                time.sleep(1)

        return len(failed) == 0
dataset/ETHPy150Open ufora/ufora/packages/python/pyfora/aws/Launcher.py/Launcher.wait_for_services/swapped operands of `not in`