|
4 | 4 |
|
5 | 5 | #include "Python-ast.h" |
6 | 6 | #undef Yield /* undefine macro conflicting with <winbase.h> */ |
7 | | -#include "pycore_coreconfig.h" |
| 7 | +#include "pycore_ceval.h" /* _PyEval_FiniThreads() */ |
8 | 8 | #include "pycore_context.h" |
| 9 | +#include "pycore_coreconfig.h" |
9 | 10 | #include "pycore_fileutils.h" |
10 | 11 | #include "pycore_hamt.h" |
11 | 12 | #include "pycore_pathconfig.h" |
@@ -555,12 +556,11 @@ pycore_create_interpreter(_PyRuntimeState *runtime, |
555 | 556 | return _Py_INIT_ERR("can't make first thread"); |
556 | 557 | (void) PyThreadState_Swap(tstate); |
557 | 558 |
|
558 | | - /* We can't call _PyEval_FiniThreads() in Py_FinalizeEx because |
559 | | - destroying the GIL might fail when it is being referenced from |
560 | | - another running thread (see issue #9901). |
| 559 | + /* Destroying the GIL in Py_FinalizeEx might fail when it is being |
| 560 | + referenced from another running thread (see bpo-9901). |
561 | 561 | Instead we destroy the previously created GIL here, which ensures |
562 | 562 | that we can call Py_Initialize / Py_FinalizeEx multiple times. */ |
563 | | - _PyEval_FiniThreads(); |
| 563 | + _PyEval_FiniThreads2(); |
564 | 564 |
|
565 | 565 | /* Auto-thread-state API */ |
566 | 566 | _PyGILState_Init(runtime, interp, tstate); |
@@ -1357,6 +1357,7 @@ Py_FinalizeEx(void) |
1357 | 1357 |
|
1358 | 1358 | call_ll_exitfuncs(runtime); |
1359 | 1359 |
|
| 1360 | + _PyEval_FiniThreads(); |
1360 | 1361 | _PyRuntime_Finalize(); |
1361 | 1362 | return status; |
1362 | 1363 | } |
|
0 commit comments