Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[pyAPI] Release GIL in AsyncInferQueue destructor to prevent deadlocks (#37073)

Pawel Raasz7b4bff2333db
diff --git a/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp b/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp
index 01e6960b034..30cb17447f9 100644
--- a/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp
+++ b/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp
@@ -1,5 +1,6 @@
// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
+//
#include "pyopenvino/core/async_infer_queue.hpp"
@@ -41,6 +42,9 @@ public:
}
~AsyncInferQueue() {
+ // Release the GIL before destroying requests. m_requests.clear() triggers a C++ destructor chain that
+ // eventually joins plugin executor threads (via CoreImpl dtor).
+ py::gil_scoped_release release;
m_requests.clear();
}
diff --git a/src/bindings/python/src/pyopenvino/core/async_infer_queue.hpp b/src/bindings/python/src/pyopenvino/core/async_infer_queue.hpp
index 188a4473aad..575d37e6c47 100644
--- a/src/bindings/python/src/pyopenvino/core/async_infer_queue.hpp
+++ b/src/bindings/python/src/pyopenvino/core/async_infer_queue.hpp
@@ -1,5 +1,6 @@
// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
+//
#pragma once
diff --git a/tests/samples_tests/smoke_tests/test_classification_sample_async.py b/tests/samples_tests/smoke_tests/test_classification_sample_async.py
index 07e0b8586bf..b71b9db6021 100644
--- a/tests/samples_tests/smoke_tests/test_classification_sample_async.py
+++ b/tests/samples_tests/smoke_tests/test_classification_sample_async.py
@@ -38,12 +38,10 @@ test_data_fp16 = get_tests({
class TestClassification(SamplesCommonTestClass):
sample_name = 'classification_sample_async'
- @pytest.mark.skip(reason="CVS-188974")
@pytest.mark.parametrize("param", test_data_fp32)
def test_classification_sample_async_fp32(self, param, cache):
_check_output(self, param, '215', cache)
- @pytest.mark.skip(reason="CVS-188974")
@pytest.mark.parametrize("param", test_data_fp16)
def test_classification_sample_async_fp16(self, param, cache):
_check_output(self, param, '215', cache)