def wait(object_ids, num_returns=1, timeout=None):
    """Return a list of IDs that are ready and a list of IDs that are not.

    .. warning::

        The **timeout** argument used to be in **milliseconds** (up through
        ``ray==0.6.1``) and now it is in **seconds**.

    If timeout is set, the function returns either when the requested number of
    IDs are ready or when the timeout is reached, whichever occurs first. If it
    is not set, the function simply waits until that number of objects is ready
    and returns that exact number of object IDs.

    This method returns two lists. The first list consists of object IDs that
    correspond to objects that are available in the object store. The second
    list corresponds to the rest of the object IDs (which may or may not be
    ready).

    Ordering of the input list of object IDs is preserved. That is, if A
    precedes B in the input list, and both are in the ready list, then A will
    precede B in the ready list. This also holds true if A and B are both in
    the remaining list.

    Args:
        object_ids (List[ObjectID]): List of object IDs for objects that may or
            may not be ready. Note that these IDs must be unique.
        num_returns (int): The number of object IDs that should be returned.
        timeout (float): The maximum amount of time in seconds to wait before
            returning.

    Returns:
        A list of object IDs that are ready and a list of the remaining object
        IDs.
    """
    worker = global_worker

    if isinstance(object_ids, ObjectID):
        raise TypeError(
            "wait() expected a list of ray.ObjectID, got a single ray.ObjectID"
        )

    if not isinstance(object_ids, list):
        raise TypeError(
            "wait() expected a list of ray.ObjectID, got {}".format(
                type(object_ids)))

    if isinstance(timeout, int) and timeout != 0:
        logger.warning("The 'timeout' argument now requires seconds instead "
                       "of milliseconds. This message can be suppressed by "
                       "passing in a float.")

    if timeout is not None and timeout < 0:
        raise ValueError("The 'timeout' argument must be nonnegative. "
                         "Received {}".format(timeout))

    if worker.mode != LOCAL_MODE:
        for object_id in object_ids:
            if not isinstance(object_id, ObjectID):
                raise TypeError("wait() expected a list of ray.ObjectID, "
                                "got list containing {}".format(
                                    type(object_id)))

    worker.check_connected()
    # TODO(swang): Check main thread.
    with profiling.profile("ray.wait"):
        # When Ray is run in LOCAL_MODE, all functions are run immediately,
        # so all objects in object_id are ready.
        if worker.mode == LOCAL_MODE:
            return object_ids[:num_returns], object_ids[num_returns:]

        # TODO(rkn): This is a temporary workaround for
        # https://github.com/ray-project/ray/issues/997. However, it should be
        # fixed in Arrow instead of here.
        if len(object_ids) == 0:
            return [], []

        if len(object_ids) != len(set(object_ids)):
            raise Exception("Wait requires a list of unique object IDs.")
        if num_returns <= 0:
            raise Exception(
                "Invalid number of objects to return %d." % num_returns)
        if num_returns > len(object_ids):
            raise Exception("num_returns cannot be greater than the number "
                            "of objects provided to ray.wait.")

        timeout = timeout if timeout is not None else 10**6
        timeout_milliseconds = int(timeout * 1000)
        ready_ids, remaining_ids = worker.raylet_client.wait(
            object_ids,
            num_returns,
            timeout_milliseconds,
            False,
            worker.current_task_id,
        )
        return ready_ids, remaining_ids
def wait ( object_ids , num_returns = 1 , timeout = None ) : worker = global_worker if isinstance ( object_ids , ObjectID ) : raise TypeError ( "wait() expected a list of ray.ObjectID, got a single ray.ObjectID" ) if not isinstance ( object_ids , list ) : raise TypeError ( "wait() expected a list of ray.ObjectID, got {}" . format ( type ( object_ids ) ) ) if isinstance ( timeout , int ) and timeout != 0 : logger . warning ( "The 'timeout' argument now requires seconds instead " "of milliseconds. This message can be suppressed by " "passing in a float." ) if timeout is not None and timeout < 0 : raise ValueError ( "The 'timeout' argument must be nonnegative. " "Received {}" . format ( timeout ) ) if worker . mode != LOCAL_MODE : for object_id in object_ids : if not isinstance ( object_id , ObjectID ) : raise TypeError ( "wait() expected a list of ray.ObjectID, " "got list containing {}" . format ( type ( object_id ) ) ) worker . check_connected ( ) with profiling . profile ( "ray.wait" ) : if worker . mode == LOCAL_MODE : return object_ids [ : num_returns ] , object_ids [ num_returns : ] if len ( object_ids ) == 0 : return [ ] , [ ] if len ( object_ids ) != len ( set ( object_ids ) ) : raise Exception ( "Wait requires a list of unique object IDs." ) if num_returns <= 0 : raise Exception ( "Invalid number of objects to return %d." % num_returns ) if num_returns > len ( object_ids ) : raise Exception ( "num_returns cannot be greater than the number " "of objects provided to ray.wait." ) timeout = timeout if timeout is not None else 10 ** 6 timeout_milliseconds = int ( timeout * 1000 ) ready_ids , remaining_ids = worker . raylet_client . wait ( object_ids , num_returns , timeout_milliseconds , False , worker . current_task_id , ) return ready_ids , remaining_ids
Return a list of IDs that are ready and a list of IDs that are not.

    .. warning::

        The **timeout** argument used to be in **milliseconds** (up through
        ``ray==0.6.1``) and now it is in **seconds**.

    If timeout is set, the function returns either when the requested number of
    IDs are ready or when the timeout is reached, whichever occurs first. If it
    is not set, the function simply waits until that number of objects is ready
    and returns that exact number of object IDs.

    This method returns two lists. The first list consists of object IDs that
    correspond to objects that are available in the object store. The second
    list corresponds to the rest of the object IDs (which may or may not be
    ready).

    Ordering of the input list of object IDs is preserved. That is, if A
    precedes B in the input list, and both are in the ready list, then A will
    precede B in the ready list. This also holds true if A and B are both in
    the remaining list.

    Args:
        object_ids (List[ObjectID]): List of object IDs for objects that may or
            may not be ready. Note that these IDs must be unique.
        num_returns (int): The number of object IDs that should be returned.
        timeout (float): The maximum amount of time in seconds to wait before
            returning.

    Returns:
        A list of object IDs that are ready and a list of the remaining object
        IDs.