Skip to content

Commit 0dba178

Browse files
committed
Add comment about thread-safety.
1 parent 2f9e499 commit 0dba178

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Python/pystate.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2691,7 +2691,12 @@ PyGILState_Ensure(void)
26912691
called Py_Initialize(). */
26922692

26932693
/* Ensure that _PyEval_InitThreads() and _PyGILState_Init() have been
2694-
called by Py_Initialize() */
2694+
called by Py_Initialize()
2695+
2696+
TODO: This isn't thread-safe. There's no protection here against
2697+
concurrent finalization of the interpreter; it's simply a guard
2698+
for *after* the interpreter has finalized.
2699+
*/
26952700
if (!_PyEval_ThreadsInitialized() || runtime->gilstate.autoInterpreterState == NULL) {
26962701
PyThread_hang_thread();
26972702
}

0 commit comments

Comments
 (0)