- ray.wait(object_refs: List[ray._raylet.ObjectRef], *, num_returns: int = 1, timeout: Optional[float] = None, fetch_local: bool = True) Tuple[List[ray._raylet.ObjectRef], List[ray._raylet.ObjectRef]] #
Return a list of IDs that are ready and a list of IDs that are not.
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 refs.
This method returns two lists. The first list consists of object refs that correspond to objects that are available in the object store. The second list corresponds to the rest of the object refs (which may or may not be ready).
Ordering of the input list of object refs 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.
This method will issue a warning if it’s running inside an async context. Instead of
ray.wait(object_refs), you can use
Related patterns and anti-patterns:
object_refs – List of
StreamingObjectRefGeneratorsfor objects that may or may not be ready. Note that these must be unique.
num_returns – The number of object refs that should be returned.
timeout – The maximum amount of time in seconds to wait before returning.
fetch_local – If True, wait for the object to be downloaded onto the local node before returning it as ready. If False, ray.wait() will not trigger fetching of objects to the local node and will return immediately once the object is available anywhere in the cluster.
A list of object refs that are ready and a list of the remaining object IDs.