| 502 | self._exit() |
| 503 | |
| 504 | async def _block(self): |
| 505 | # Block until the barrier is ready for us, |
| 506 | # or raise an exception if it is broken. |
| 507 | # |
| 508 | # It is draining or resetting, wait until done |
| 509 | # unless a CancelledError occurs |
| 510 | await self._cond.wait_for( |
| 511 | lambda: self._state not in ( |
| 512 | _BarrierState.DRAINING, _BarrierState.RESETTING |
| 513 | ) |
| 514 | ) |
| 515 | |
| 516 | # see if the barrier is in a broken state |
| 517 | if self._state is _BarrierState.BROKEN: |
| 518 | raise exceptions.BrokenBarrierError("Barrier aborted") |
| 519 | |
| 520 | async def _release(self): |
| 521 | # Release the tasks waiting in the barrier. |