By default, wake up one task waiting on this condition, if any. If the calling task has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up n of the tasks waiting for the condition variable; if fewer than n are waiting, t
(self, n: int = 1)
| 275 | return result |
| 276 | |
| 277 | def notify(self, n: int = 1) -> None: |
| 278 | """By default, wake up one task waiting on this condition, if any. |
| 279 | If the calling task has not acquired the lock when this method |
| 280 | is called, a RuntimeError is raised. |
| 281 | |
| 282 | This method wakes up n of the tasks waiting for the condition |
| 283 | variable; if fewer than n are waiting, they are all awoken. |
| 284 | |
| 285 | Note: an awakened task does not actually return from its |
| 286 | wait() call until it can reacquire the lock. Since notify() does |
| 287 | not release the lock, its caller should. |
| 288 | """ |
| 289 | if not self.locked(): |
| 290 | raise RuntimeError("cannot notify on un-acquired lock") |
| 291 | self._notify(n) |
| 292 | |
| 293 | def _notify(self, n: int) -> None: |
| 294 | idx = 0 |