File tree Expand file tree Collapse file tree 1 file changed +3
-15
lines changed
Expand file tree Collapse file tree 1 file changed +3
-15
lines changed Original file line number Diff line number Diff line change @@ -95,29 +95,17 @@ async def op(
9595
9696
9797class Barrier :
98- """Minimal implementation of asyncio.Barrier for Python 3.9+ compatibility.
99-
100- This is a simplified version that only implements the wait() method needed
101- for this test. All tasks block until exactly 'parties' tasks have called
102- wait(), then all are released simultaneously.
103- """
104-
10598 def __init__ (self , parties : int ):
10699 """Create a barrier for 'parties' tasks."""
107100 if parties < 1 :
108101 raise ValueError ("parties must be > 0" )
109102 self ._parties = parties
110103 self ._count = 0
111- self ._lock = asyncio .Lock ()
112104 self ._event = asyncio .Event ()
113105
114106 async def wait (self ) -> None :
115107 """Wait for all parties to reach the barrier."""
116- async with self ._lock :
117- self ._count += 1
118- if self ._count == self ._parties :
119- # Last one in, release everyone
120- self ._event .set ()
121-
122- # Wait for all parties to arrive
108+ self ._count += 1
109+ if self ._count == self ._parties :
110+ self ._event .set ()
123111 await self ._event .wait ()
You can’t perform that action at this time.
0 commit comments