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)
| 341 | pass |
| 342 | |
| 343 | def wait_for(self, predicate, timeout=None): |
| 344 | """Wait until a condition evaluates to True. |
| 345 | |
| 346 | predicate should be a callable which result will be interpreted as a |
| 347 | boolean value. A timeout may be provided giving the maximum time to |
| 348 | wait. |
| 349 | |
| 350 | """ |
| 351 | endtime = None |
| 352 | waittime = timeout |
| 353 | result = predicate() |
| 354 | while not result: |
| 355 | if waittime is not None: |
| 356 | if endtime is None: |
| 357 | endtime = _time() + waittime |
| 358 | else: |
| 359 | waittime = endtime - _time() |
| 360 | if waittime <= 0: |
| 361 | break |
| 362 | self.wait(waittime) |
| 363 | result = predicate() |
| 364 | return result |
| 365 | |
| 366 | def notify(self, n=1): |
| 367 | """Wake up one or more threads waiting on this condition, if any. |
no test coverage detected