Wait until a predicate becomes true. The predicate should be a callable whose result will be interpreted as a boolean value. The method will repeatedly wait() until it evaluates to true. The final predicate value is the return value.
(self, predicate: Any)
| 261 | raise |
| 262 | |
| 263 | async def wait_for(self, predicate: Any) -> Coroutine[Any, Any, Any]: |
| 264 | """Wait until a predicate becomes true. |
| 265 | |
| 266 | The predicate should be a callable whose result will be |
| 267 | interpreted as a boolean value. The method will repeatedly |
| 268 | wait() until it evaluates to true. The final predicate value is |
| 269 | the return value. |
| 270 | """ |
| 271 | result = predicate() |
| 272 | while not result: |
| 273 | await self.wait() |
| 274 | result = predicate() |
| 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. |