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)
| 301 | raise |
| 302 | |
| 303 | async def wait_for(self, predicate): |
| 304 | """Wait until a predicate becomes true. |
| 305 | |
| 306 | The predicate should be a callable whose result will be |
| 307 | interpreted as a boolean value. The method will repeatedly |
| 308 | wait() until it evaluates to true. The final predicate value is |
| 309 | the return value. |
| 310 | """ |
| 311 | result = predicate() |
| 312 | while not result: |
| 313 | await self.wait() |
| 314 | result = predicate() |
| 315 | return result |
| 316 | |
| 317 | def notify(self, n=1): |
| 318 | """By default, wake up one task waiting on this condition, if any. |