Skip to content

Commit a712679

Browse files
authored
bpo-36333, bpo-36356: Fix _PyEval_FiniThreads() (GH-12432)
_PyEval_FiniThreads() now free the pending lock.
1 parent 29198ea commit a712679

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Python/ceval.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ PyEval_ThreadsInitialized(void)
169169
void
170170
PyEval_InitThreads(void)
171171
{
172-
if (gil_created())
172+
if (gil_created()) {
173173
return;
174+
}
175+
174176
PyThread_init_thread();
175177
create_gil();
176178
take_gil(_PyThreadState_GET());
@@ -184,10 +186,17 @@ PyEval_InitThreads(void)
184186
void
185187
_PyEval_FiniThreads(void)
186188
{
187-
if (!gil_created())
189+
if (!gil_created()) {
188190
return;
191+
}
192+
189193
destroy_gil();
190194
assert(!gil_created());
195+
196+
if (_PyRuntime.ceval.pending.lock != NULL) {
197+
PyThread_free_lock(_PyRuntime.ceval.pending.lock);
198+
_PyRuntime.ceval.pending.lock = NULL;
199+
}
191200
}
192201

193202
void

0 commit comments

Comments
 (0)