Skip to content

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 <[email protected]>
@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 only 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 <[email protected]>
@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 only 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 <[email protected]>
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 <[email protected]>
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 1, 2025
The call to `with self.subTest(...)` was not thread-safe.
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
The call to `with self.subTest(...)` was not thread-safe.
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.

4 participants