MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / wait_for

Method wait_for

tools/python-3.11.9-amd64/Lib/threading.py:343–364  ·  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

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.

Callers 2

_waitMethod · 0.45

Calls 2

waitMethod · 0.95
predicateFunction · 0.85

Tested by

no test coverage detected