fix serving gil

Signed-off-by: zhoufeng <zhoufeng54@huawei.com>
This commit is contained in:
zhoufeng 2022-03-11 16:42:15 +08:00
parent 0b1ec574cf
commit dc2633df03
1 changed files with 5 additions and 1 deletions

View File

@ -28,7 +28,11 @@ namespace py = pybind11;
namespace mindspore {
class GilScopedLongRunningHook : public ScopedLongRunningHook {
public:
void Enter() override { release_ = std::make_unique<py::gil_scoped_release>(); }
void Enter() override {
if (PyGILState_Check() != 0) {
release_ = std::make_unique<py::gil_scoped_release>();
}
}
void Leave() override { release_ = nullptr; }
private: