From dc2633df03a2aa459c86b3dad46696d96d52efe3 Mon Sep 17 00:00:00 2001 From: zhoufeng Date: Fri, 11 Mar 2022 16:42:15 +0800 Subject: [PATCH] fix serving gil Signed-off-by: zhoufeng --- mindspore/ccsrc/pybind_api/gil_scoped_long_running.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mindspore/ccsrc/pybind_api/gil_scoped_long_running.h b/mindspore/ccsrc/pybind_api/gil_scoped_long_running.h index 7b2d259ee76..bb647fb8216 100644 --- a/mindspore/ccsrc/pybind_api/gil_scoped_long_running.h +++ b/mindspore/ccsrc/pybind_api/gil_scoped_long_running.h @@ -28,7 +28,11 @@ namespace py = pybind11; namespace mindspore { class GilScopedLongRunningHook : public ScopedLongRunningHook { public: - void Enter() override { release_ = std::make_unique(); } + void Enter() override { + if (PyGILState_Check() != 0) { + release_ = std::make_unique(); + } + } void Leave() override { release_ = nullptr; } private: