You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Barrier hangs indefinitely when arg parties < 0 or invalid type #121474
threading.Barrier at no point checks for valid parties. parties, of a negative value, or invalid type hang indefinitely on .wait(). This behavior is inconsistent from the behavior of any other threading primitives, which either conduct sanity checks on args during initialization, or fail at some point in their execution.
Steps to reproduce:
fromthreadingimportBarrier# negativebarrier=Barrier(-1) # <threading.Barrier at 0x10aa789b0: waiters=0/-1>barrier.wait()
# invalid type stringbarrier=Barrier("test") # <threading.Barrier at 0x10ae64980: waiters=0/test>barrier.wait()
# invalid type floatbarrier=Barrier(0.5) # <threading.Barrier at 0x10aa7a570: waiters=0/0.5>barrier.wait()
# invalid type objectbarrier=Barrier(object()) # <threading.Barrier at 0x10ae4f500: waiters=0/<object object at 0x10a878730>>barrier.wait()
changed the title [-]Barrier hangs indefinitely when arg `parties` < 0[/-][+]Barrier hangs indefinitely when arg `parties` < 0 or invalid type[/+]on Jul 8, 2024
Activity
[-]Barrier hangs indefinitely when arg `parties` < 0[/-][+]Barrier hangs indefinitely when arg `parties` < 0 or invalid type[/+]pythongh-121474: Added Barrier `parties` sanity chack.
pythongh-121474: Added test.
graingert commentedon Jul 8, 2024
asyncio.Barrier has this validation https://github.com/python/cpython/blob/3.12/Lib/asyncio/locks.py#L457
pygeek commentedon Jul 8, 2024
This issue is not related to
async.Barrier. This is a bug inthreading.Barrierhttps://github.com/python/cpython/blob/3.12/Lib/threading.py#L670
graingert commentedon Jul 8, 2024
I'm aware. My point is that asyncio.Barrier has this validation so threading.Barrier should have it also
pythongh-121474: Fixed sanity check.
pythongh-121474: Added Barrier `parties` sanity chack.
pythongh-121474: Add blurb.
pythongh-121474: Add `threading.Barrier` `parties` arg sanity chack.
pythongh-121474: Add `threading.Barrier` `parties` arg sanity check.
pythongh-121474: Add `threading.Barrier` `parties` arg sanity check.
pythongh-121474: Add `threading.Barrier` `parties` arg sanity check.
gh-121474: Add threading.Barrier parties arg sanity check. (GH-121480)
pythongh-121474: Add threading.Barrier parties arg sanity check. (pyt…
pythongh-121474: Add threading.Barrier parties arg sanity check. (pyt…
[3.12] gh-121474: Add threading.Barrier parties arg sanity check. (GH…
[3.13] gh-121474: Add threading.Barrier parties arg sanity check. (GH…
pythongh-121474: Add threading.Barrier parties arg sanity check. (pyt…