| 35 | |
| 36 | |
| 37 | class CounterEvent(asyncio.Event): |
| 38 | |
| 39 | def __init__(self): |
| 40 | super().__init__() |
| 41 | self._counter = 0 |
| 42 | |
| 43 | def set(self): |
| 44 | if self._counter > 0: |
| 45 | self._counter -= 1 |
| 46 | if self._counter == 0: |
| 47 | super().set() |
| 48 | |
| 49 | def clear(self): |
| 50 | if self._counter == 0 and super().is_set(): |
| 51 | super().clear() |
| 52 | self._counter += 1 |
| 53 | |
| 54 | |
| 55 | class RunableEventAsync: |