diff --git a/docs/OV_Runtime_UG/Python_API_exclusives.md b/docs/OV_Runtime_UG/Python_API_exclusives.md index 7d15c474d35..c1824186fef 100644 --- a/docs/OV_Runtime_UG/Python_API_exclusives.md +++ b/docs/OV_Runtime_UG/Python_API_exclusives.md @@ -120,6 +120,10 @@ The ``start_async`` function call is not required to be synchronized - it waits :language: python :fragment: [asyncinferqueue] +.. warning:: + + ``InferRequest`` objects that can be acquired by iterating over a ``AsyncInferQueue`` object or by ``[id]`` guaranteed to work with read-only methods like getting tensors. + Any mutating methods (e.g. start_async, set_callback) of a single request will put the parent AsyncInferQueue object in an invalid state. Acquiring Results from Requests ------------------------------- diff --git a/src/bindings/python/src/openvino/runtime/ie_api.py b/src/bindings/python/src/openvino/runtime/ie_api.py index 90099609a1a..9e0161daebf 100644 --- a/src/bindings/python/src/openvino/runtime/ie_api.py +++ b/src/bindings/python/src/openvino/runtime/ie_api.py @@ -280,6 +280,10 @@ class AsyncInferQueue(AsyncInferQueueBase): def __iter__(self) -> Iterable[InferRequest]: """Allows to iterate over AsyncInferQueue. + Resulting objects are guaranteed to work with read-only methods like getting tensors. + Any mutating methods (e.g. start_async, set_callback) of a single request + will put the parent AsyncInferQueue object in an invalid state. + :return: a generator that yields InferRequests. :rtype: Iterable[openvino.runtime.InferRequest] """ @@ -288,6 +292,10 @@ class AsyncInferQueue(AsyncInferQueueBase): def __getitem__(self, i: int) -> InferRequest: """Gets InferRequest from the pool with given i id. + Resulting object is guaranteed to work with read-only methods like getting tensors. + Any mutating methods (e.g. start_async, set_callback) of a request + will put the parent AsyncInferQueue object in an invalid state. + :param i: InferRequest id. :type i: int :return: InferRequests from the pool with given id.