Skip to content

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

Open
miss-islington wants to merge 1 commit into
python:3.14from
miss-islington:backport-388e023-3.14
Open

[3.14] gh-150175: Fix ThreadingMock call_count race condition (GH-150176)#150181
miss-islington wants to merge 1 commit into
python:3.14from
miss-islington:backport-388e023-3.14

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 156835592+saisneha196@users.noreply.github.com

…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 <156835592+saisneha196@users.noreply.github.com>
@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

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants