Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-131677: Fix flaky test_lru_cache_threaded3 #131679

Merged

Conversation

colesbury
Copy link
Contributor

@colesbury colesbury commented Mar 24, 2025

The call to with self.subTest(...) was not thread-safe.

The call to `with self.subTest(...)` was not thread-safe.
@colesbury colesbury requested a review from vstinner March 24, 2025 16:06
@colesbury colesbury requested a review from rhettinger as a code owner March 24, 2025 16:06
@bedevere-app bedevere-app bot added tests Tests in the Lib/test dir awaiting core review labels Mar 24, 2025
@rhettinger rhettinger requested review from serhiy-storchaka and removed request for rhettinger March 24, 2025 16:53
@rhettinger
Copy link
Contributor

@serhiy-storchaka This is your code. Do you want to take a look?

@colesbury Can subTest be made thread-safe?

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@colesbury
Copy link
Contributor Author

Can subTest be made thread-safe?

I think practically you'd have to get rid of self._subtest in unittest.TestCase and I'd generally be a bit concerned about that sort of change for something as widely used as unittest

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

Surprised that it did not fail more often. 🤔

@rhettinger
Copy link
Contributor

As you fix these, perhaps keep a list of tools that are intrinsically single-threaded. Such as list might be useful for linters and it might make a good FAQ entry.

@colesbury colesbury merged commit a123245 into python:main Mar 24, 2025
48 checks passed
@colesbury colesbury deleted the gh-131677-flaky-test_lru_cache_threaded3 branch March 24, 2025 20:41
@colesbury colesbury added the needs backport to 3.13 bugs and security fixes label Mar 24, 2025
@miss-islington-app
Copy link

Thanks @colesbury for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 24, 2025
The call to `with self.subTest(...)` was not thread-safe.
(cherry picked from commit a123245)

Co-authored-by: Sam Gross <colesbury@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Mar 24, 2025

GH-131692 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Mar 24, 2025
@colesbury colesbury added the needs backport to 3.12 bug and security fixes label Mar 24, 2025
@miss-islington-app
Copy link

Thanks @colesbury for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 24, 2025
The call to `with self.subTest(...)` was not thread-safe.
(cherry picked from commit a123245)

Co-authored-by: Sam Gross <colesbury@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Mar 24, 2025

GH-131693 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Mar 24, 2025
colesbury added a commit that referenced this pull request Mar 24, 2025
…131693)

The call to `with self.subTest(...)` was not thread-safe.
(cherry picked from commit a123245)

Co-authored-by: Sam Gross <colesbury@gmail.com>
colesbury added a commit that referenced this pull request Mar 24, 2025
…131692)

The call to `with self.subTest(...)` was not thread-safe.
(cherry picked from commit a123245)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants