Skip to content

Conversation

@chaope
Copy link

@chaope chaope commented Dec 13, 2025

gh-142651: Make call_count of Mock thread safe

@chaope chaope requested a review from cjw296 as a code owner December 13, 2025 06:15
@bedevere-app
Copy link

bedevere-app bot commented Dec 13, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

import concurrent.futures

from test.support import threading_helper
from test.support import setswitchinterval, threading_helper
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me think that we should have this as a context manager instead but this is a separate issue. I'll do it tomorrow myself.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to do it in a separate PR? I can create a new PR for context manager.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you but I will need to check if it'll be useful in much places and whether it could create conflicts with backports (usually refactoring and new features in tests are annoying because it creates differences with older branches).

Copy link
Author

@chaope chaope Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I think adding a context manager would be a good practice for me to learn and involve more in CPython development. Do you mind me giving it a try? Is there a sample PR you would like me to follow? How would you evaluate it being useful? (Like will be used in more than x places?)

also, do we need to back port this change to older versions? If so, may I also give it a try? Is there any pending steps before we want to merge this PR? (Saw that you have requested a review from @cjw296 , assuming that is the next step?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I was not clear but I want to investigate on my side first. If we were to do it, this could be an easy task but I do not want to create an issue or a PR unless I see whether it will be really useful.

Copy link
Member

@picnixz picnixz Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for backporting this PR here, we have an automated way to do it. If the backport fails you can do a manual one later

@kumaraditya303 kumaraditya303 added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants