-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Avoid thread termination in scoped_released #2657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
7e8a4cf
9e8bd73
c82145d
7b70787
461e81a
f5804e3
e5fe8d3
bb8cee6
93639b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2121,7 +2121,12 @@ class gil_scoped_acquire { | |
| pybind11_fail("scoped_acquire::dec_ref(): internal error!"); | ||
| #endif | ||
| PyThreadState_Clear(tstate); | ||
| #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 6) && !defined(Py_LIMITED_API) | ||
| if (!_Py_IsFinalizing()) | ||
| PyThreadState_DeleteCurrent(); | ||
| #else | ||
| PyThreadState_DeleteCurrent(); | ||
| #endif | ||
| PYBIND11_TLS_DELETE_VALUE(detail::get_internals().tstate); | ||
| release = false; | ||
| } | ||
|
|
@@ -2153,7 +2158,14 @@ class gil_scoped_release { | |
| ~gil_scoped_release() { | ||
| if (!tstate) | ||
| return; | ||
| #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 6) && !defined(Py_LIMITED_API) | ||
| // PyEval_RestoreThread() should not be called if runtime is finilizing | ||
| // See https://docs.python.org/3/c-api/init.html#c.PyEval_RestoreThread | ||
| if (!_Py_IsFinalizing()) | ||
| PyEval_RestoreThread(tstate); | ||
| #else | ||
|
||
| PyEval_RestoreThread(tstate); | ||
| #endif | ||
| if (disassoc) { | ||
| auto key = detail::get_internals().tstate; | ||
| PYBIND11_TLS_REPLACE_VALUE(key, tstate); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.