-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-121474: Add threading.Barrier parties arg sanity check. #121480
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
Conversation
parties
sanity chack.parties
sanity chack.
parties
sanity chack.6878079
to
58880e2
Compare
This matches the asyncio.Barrier now, which is great. But I notice neither handle 1.5 and other non-integral floats well |
I noticed this too, but neither do any of the primitives in I plan on creating a separate Discuss thread on the matter, once/if this current PR is merged. My guess is that since the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, other than a nitpick and PEP 8 compliance 🙂
Lib/test/lock_tests.py
Outdated
@@ -1013,6 +1013,10 @@ def multipass(self, results, n): | |||
self.assertEqual(self.barrier.n_waiting, 0) | |||
self.assertFalse(self.barrier.broken) | |||
|
|||
def test_constructor(self): | |||
self.assertRaises(ValueError, self.barriertype, parties = 0) | |||
self.assertRaises(ValueError, self.barriertype, parties = -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.assertRaises(ValueError, self.barriertype, parties = -1) | |
self.assertRaises(ValueError, self.barriertype, parties=-1) |
Lib/test/lock_tests.py
Outdated
@@ -1013,6 +1013,10 @@ def multipass(self, results, n): | |||
self.assertEqual(self.barrier.n_waiting, 0) | |||
self.assertFalse(self.barrier.broken) | |||
|
|||
def test_constructor(self): | |||
self.assertRaises(ValueError, self.barriertype, parties = 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.assertRaises(ValueError, self.barriertype, parties = 0) | |
self.assertRaises(ValueError, self.barriertype, parties=0) |
Nice catch. I don't think the linter runs on test files. I literally copied the check from https://github.com/python/cpython/pull/121480/files/58880e2d5387680385e3802d8e18d2d2de8ef470#diff-1d04f1b4512c48ecc14e3eae5713be5dea3bdbeba07f9d77bb08089103c880dbL754-L755 . I'm not sure if the omission of the linter is intentional. Edit: I double checked. There is a linter on Lib/tests, but |
Probably not, and out of the scope of this issue anyways. |
I was speaking more generally, outside the context of this PR. Anyway, I'll start a separate thread in Discuss on the topic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks @pygeek for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Thanks @pygeek for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…honGH-121480) (cherry picked from commit d27a53f) Co-authored-by: Clinton <pygeek@users.noreply.github.com>
…honGH-121480) (cherry picked from commit d27a53f) Co-authored-by: Clinton <pygeek@users.noreply.github.com>
GH-122443 is a backport of this pull request to the 3.12 branch. |
GH-122444 is a backport of this pull request to the 3.13 branch. |
Thank you for your contribution @pygeek. |
parties
< 0 or invalid type #121474