Skip to content

[3.13] gh-150175: Fix ThreadingMock call_count race condition (GH-150176)#150180

Merged
gpshead merged 1 commit into
python:3.13from
miss-islington:backport-388e023-3.13
May 26, 2026
Merged

[3.13] gh-150175: Fix ThreadingMock call_count race condition (GH-150176)#150180
gpshead merged 1 commit into
python:3.13from
miss-islington:backport-388e023-3.13

Conversation

@miss-islington
Copy link
Copy Markdown
Contributor

@miss-islington miss-islington commented May 21, 2026

ThreadingMock._increment_mock_call() was not thread-safe.
Multiple threads calling the mock simultaneously could lose
increments due to race conditions on call_count and other
attributes.

Fix by overriding _increment_mock_call in ThreadingMixin
and wrapping it with the existing _mock_calls_events_lock.
(cherry picked from commit 388e023)

Co-authored-by: saisneha196 [email protected]

…H-150176)

ThreadingMock._increment_mock_call() was not thread-safe.
Multiple threads calling the mock simultaneously could lose
increments due to race conditions on call_count and other
attributes.

Fix by overriding _increment_mock_call in ThreadingMixin
and wrapping it with the existing _mock_calls_events_lock.
(cherry picked from commit 388e023)

Co-authored-by: saisneha196 <[email protected]>
@miss-islington miss-islington requested a review from cjw296 as a code owner May 21, 2026 08:11
@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented May 21, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@cjw296
Copy link
Copy Markdown
Contributor

cjw296 commented May 21, 2026

I'm confused, #150176 says CLA was signed, so why the complaint here?

@gpshead gpshead merged commit 43f71b0 into python:3.13 May 26, 2026
45 checks passed
@miss-islington miss-islington deleted the backport-388e023-3.13 branch May 26, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants