Skip to content

Commit 1a200bf

Browse files
committed
gh-151518: Wake only registered attach waiters
Avoid a parking-lot lookup when resuming a suspended thread that has not tried to reattach. Use the old state from the successful CAS so concurrent waiter registration still receives a wakeup.
1 parent 4093ea6 commit 1a200bf

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎Python/pystate.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,9 @@ _PyThreadState_ResumeDetached(PyThreadState *tstate)
24412441
} while (!_Py_atomic_compare_exchange_int(
24422442
&tstate->state, &state, next_state));
24432443
// Wake the thread if it is parked in tstate_wait_attach().
2444-
_PyParkingLot_UnparkAll(&tstate->state);
2444+
if (state == _Py_THREAD_SUSPENDED_WAITING) {
2445+
_PyParkingLot_UnparkAll(&tstate->state);
2446+
}
24452447
}
24462448
#endif
24472449

0 commit comments

Comments
 (0)