yr.get#
- yr.get(obj_refs: ObjectRef | List | RgObjectRef, timeout: int = 300, allow_partial: bool = False) object[source]#
Retrieve the value of an object stored in the backend based on the object’s key. The interface call will block until the object’s value is obtained or a timeout occurs.
Note
yr.get() uniformly returns a memoryview pointer for bytes, bytearray, and memoryview types.
- Parameters:
obj_refs (ObjectRef, List[ObjectRef]) – The object_ref of the object in the data system.
timeout (int, optional) – The timeout value. A value of -1 means wait indefinitely. Limit: -1, (0, ∞). Defaults to
300.allow_partial (bool, optional) – If set to False, the get interface will throw an exception when the data system returns partial results within the timeout period. If set to True, the get interface will return a list of objects and fill failed objects with None. Default is
_DEFAULT_ALLOW_PARTIAL.
- Returns:
A Python object or a list of Python objects.
- Raises:
ValueError – If the input parameter type is incorrect.
RuntimeError – If obtaining the object from the data system fails.
YRInvokeError – If the function execution fails.
TimeoutError – If the results of all object references cannot be obtained within the specified timeout period.
Examples
>>> import yr >>> yr.init() >>> >>> @yr.invoke() >>> def add(a, b): ... return a + b >>> obj_ref_1 = add.invoke(1, 2) >>> obj_ref_2 = add.invoke(3, 4) >>> result = yr.get([obj_ref_1, obj_ref_2], timeout=-1) >>> print(result) >>> yr.finalize()