Wait until a condition evaluates to True. predicate should be a callable which result will be interpreted as a boolean value. A timeout may be provided giving the maximum time to wait.
(self, predicate, timeout=None)
| 383 | pass |
| 384 | |
| 385 | def wait_for(self, predicate, timeout=None): |
| 386 | """Wait until a condition evaluates to True. |
| 387 | |
| 388 | predicate should be a callable which result will be interpreted as a |
| 389 | boolean value. A timeout may be provided giving the maximum time to |
| 390 | wait. |
| 391 | |
| 392 | """ |
| 393 | endtime = None |
| 394 | waittime = timeout |
| 395 | result = predicate() |
| 396 | while not result: |
| 397 | if waittime is not None: |
| 398 | if endtime is None: |
| 399 | endtime = _time() + waittime |
| 400 | else: |
| 401 | waittime = endtime - _time() |
| 402 | if waittime <= 0: |
| 403 | break |
| 404 | self.wait(waittime) |
| 405 | result = predicate() |
| 406 | return result |
| 407 | |
| 408 | def notify(self, n=1): |
| 409 | """Wake up one or more threads waiting on this condition, if any. |
no test coverage detected