ray.get#

ray.get(object_refs: Sequence[ObjectRef[Any]], *, timeout: float | None = None) List[Any][source]#
ray.get(object_refs: Sequence[ObjectRef[R]], *, timeout: float | None = None) List[R]
ray.get(object_refs: ObjectRef[R], *, timeout: float | None = 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_ref instead of ray.get(object_ref). For a list of object refs, you can use await asyncio.gather(*object_refs).

Passing ObjectRefGenerator is not allowed.

Related patterns and anti-patterns:

Parameters:
  • 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. Setting timeout=0 will return the object immediately if it’s available, else raise GetTimeoutError in accordance with the above docstring.

Returns:

A Python object or a list of Python objects.

Raises:
  • 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.