Skip to content

Commit f3e6821

Browse files
committed
Simplify
1 parent e5bc027 commit f3e6821

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

tests/nexus/test_worker.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,17 @@ async def op(
9595

9696

9797
class 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()

0 commit comments

Comments
 (0)