Skip to content

Commit 5fd5336

Browse files
Fix clearing of executors
1 parent 8be3b2f commit 5fd5336

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Python/optimizer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,12 +1669,14 @@ executor_clear(PyObject *op)
16691669
* free the executor unless we hold a strong reference to it
16701670
*/
16711671
_PyExecutorObject *cold = _PyExecutor_GetColdExecutor();
1672+
_PyExecutorObject *cold_dynamic = _PyExecutor_GetColdDynamicExecutor();
16721673
Py_INCREF(executor);
16731674
for (uint32_t i = 0; i < executor->exit_count; i++) {
16741675
executor->exits[i].temperature = initial_unreachable_backoff_counter();
16751676
_PyExecutorObject *e = executor->exits[i].executor;
1676-
executor->exits[i].executor = cold;
1677-
Py_DECREF(e);
1677+
if (e != cold && e != cold_dynamic) {
1678+
executor_clear(e);
1679+
}
16781680
}
16791681
_Py_ExecutorDetach(executor);
16801682
Py_DECREF(executor);

0 commit comments

Comments
 (0)