MCPcopy Index your code
hub / github.com/python/cpython / wait_for

Method wait_for

Lib/asyncio/locks.py:303–315  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 7

test_waitforMethod · 0.95
test_cancelled_wakeupMethod · 0.95
_blockMethod · 0.45
_waitMethod · 0.45
run_one_coroFunction · 0.45

Calls 1

waitMethod · 0.95

Tested by 4

test_waitforMethod · 0.76
test_cancelled_wakeupMethod · 0.76