MCPcopy Create free account
hub / github.com/pybind/pybind11 / ~subinterpreter_scoped_activate

Method ~subinterpreter_scoped_activate

include/pybind11/subinterpreter.h:270–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270inline subinterpreter_scoped_activate::~subinterpreter_scoped_activate() {
271 if (simple_gil_) {
272 // We were on this interpreter already, so just make sure the GIL goes back as it was
273 PyGILState_Release(gil_state_);
274 } else {
275 if (tstate_) {
276#if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
277 if (detail::get_thread_state_unchecked() != tstate_) {
278 pybind11_fail("~subinterpreter_scoped_activate: thread state must be current!");
279 }
280#endif
281 detail::get_internals().tstate.reset();
282 PyThreadState_Clear(tstate_);
283 PyThreadState_DeleteCurrent();
284 }
285
286 // Go back the previous interpreter (if any) and acquire THAT gil
287 PyThreadState_Swap(old_tstate_);
288 }
289}
290
291PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected