!49930 Add Python env check before release GIL
Merge pull request !49930 from caifubi/master-pynative-gil-bugfix
This commit is contained in:
commit
ff8a2d16c6
|
@ -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