File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -114,9 +114,20 @@ EnvironmentPtr Environment::get()
114114
115115 auto init = []()
116116 {
117+ PyGILState_STATE gstate;
118+
119+ // If the interpreter is already initialized, we need to
120+ // grab the GIL and hold it before we go do any Python
121+ // stuff
122+ bool alreadyInitialized (Py_IsInitialized ());
123+ if (alreadyInitialized)
124+ gstate = PyGILState_Ensure ();
125+
117126 g_environment = new Environment ();
127+
128+ if (alreadyInitialized)
129+ PyGILState_Release (gstate);
118130 };
119- gil_scoped_acquire acquire;
120131 std::call_once (flag, init);
121132 return g_environment;
122133}
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ class gil_scoped_release {
4545};
4646
4747
48+
49+
4850} // plang
4951
5052} // pdal
You can’t perform that action at this time.
0 commit comments