Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 17548dd commit 068f81eCopy full SHA for 068f81e
1 file changed
Python/pystate.c
@@ -423,6 +423,14 @@ PyThreadState_DeleteCurrent()
423
Py_FatalError(
424
"PyThreadState_DeleteCurrent: no current tstate");
425
_Py_atomic_store_relaxed(&_PyThreadState_Current, NULL);
426
+ /*
427
+ Only call tstate_delete_common to have the tstate if we're not finalizing
428
+ or we're the main thread. The main thread will do this for us. Not calling
429
+ tstate_delete_common means we won't lock the interpreter head lock,
430
+ avoiding a possible deadlock with the GIL.
431
+ */
432
+ if (!_Py_Finalizing || _Py_Finalizing == tstate)
433
+ tstate_delete_common(tstate);
434
if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate)
435
PyThread_delete_key_value(autoTLSkey);
436
tstate_delete_common(tstate);
0 commit comments