| 532 | self._exit() |
| 533 | |
| 534 | async def _block(self): |
| 535 | # Block until the barrier is ready for us, |
| 536 | # or raise an exception if it is broken. |
| 537 | # |
| 538 | # It is draining or resetting, wait until done |
| 539 | # unless a CancelledError occurs |
| 540 | await self._cond.wait_for( |
| 541 | lambda: self._state not in ( |
| 542 | _BarrierState.DRAINING, _BarrierState.RESETTING |
| 543 | ) |
| 544 | ) |
| 545 | |
| 546 | # see if the barrier is in a broken state |
| 547 | if self._state is _BarrierState.BROKEN: |
| 548 | raise exceptions.BrokenBarrierError("Barrier aborted") |
| 549 | |
| 550 | async def _release(self): |
| 551 | # Release the tasks waiting in the barrier. |