forked from mindspore-Ecosystem/mindspore
Add Python env check for gil
This commit is contained in:
parent
e2ac12b1ad
commit
ffb5c55b6c
|
@ -42,7 +42,7 @@ class GilScopedLongRunningHook : public ScopedLongRunningHook {
|
|||
class GilReleaseWithCheck {
|
||||
public:
|
||||
GilReleaseWithCheck() {
|
||||
if (PyGILState_Check() != 0) {
|
||||
if (Py_IsInitialized() != 0 && PyGILState_Check() != 0) {
|
||||
release_ = std::make_unique<py::gil_scoped_release>();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue