- ray.get(object_refs: Sequence[ObjectRef[Any]], *, timeout: Optional[float] = 'None') List[Any] [source]#
- ray.get(object_refs: Sequence[ObjectRef[R]], *, timeout: Optional[float] = 'None') List[R]
- ray.get(object_refs: ObjectRef[R], *, timeout: Optional[float] = 'None') R
Get a remote object or a list of remote objects from the object store.
This method blocks until the object corresponding to the object ref is available in the local object store. If this object is not in the local object store, it will be shipped from an object store that has it (once the object has been created). If object_refs is a list, then the objects corresponding to each object in the list will be returned.
Ordering for an input list of object refs is preserved for each object returned. That is, if an object ref to A precedes an object ref to B in the input list, then A will precede B in the returned list.
This method will issue a warning if it’s running inside async context, you can use
await object_refinstead of
ray.get(object_ref). For a list of object refs, you can use
Related patterns and anti-patterns:
Anti-pattern: Calling ray.get unnecessarily harms performance
Anti-pattern: Processing results in submission order using ray.get increases runtime
Anti-pattern: Fetching too many objects at once with ray.get causes failure
object_refs – Object ref of the object to get or a list of object refs to get.
timeout (Optional[float]) – The maximum amount of time in seconds to wait before returning. Set this to None will block until the corresponding object becomes available. WARNING: In future ray releases
timeout=0will return the object immediately if it’s available, else raise GetTimeoutError in accordance with the above docstring. The current behavior of blocking until objects become available of
timeout=0is considered to be a bug, see https://github.com/ray-project/ray/issues/28465.
A Python object or a list of Python objects.
GetTimeoutError – A GetTimeoutError is raised if a timeout is set and the get takes longer than timeout to return.
Exception – An exception is raised if the task that created the object or that created one of the objects raised an exception.
PublicAPI: This API is stable across Ray releases.