MCPcopy Index your code
hub / github.com/RustPython/RustPython / wait_for

Method wait_for

Lib/threading.py:385–406  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 3

_waitMethod · 0.45
watchdog_threadFunction · 0.45
join_internalMethod · 0.45

Calls 3

waitMethod · 0.95
_timeFunction · 0.90
predicateFunction · 0.85

Tested by

no test coverage detected