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

Function sleep

Lib/asyncio/tasks.py:687–704  ·  view source on GitHub ↗

Coroutine that completes after a given time (in seconds).

(delay, result=None)

Source from the content-addressed store, hash-verified

685
686
687async def sleep(delay, result=None):
688 """Coroutine that completes after a given time (in seconds)."""
689 if delay <= 0:
690 await __sleep0()
691 return result
692
693 if math.isnan(delay):
694 raise ValueError("Invalid delay: NaN (not a number)")
695
696 loop = events.get_running_loop()
697 future = loop.create_future()
698 h = loop.call_later(delay,
699 futures._set_result_unless_cancelled,
700 future, result)
701 try:
702 return await future
703 finally:
704 h.cancel()
705
706
707def ensure_future(coro_or_future, *, loop=None):

Callers 10

writeMethod · 0.85
drainMethod · 0.85
test_selectorMethod · 0.85
coroMethod · 0.85
doitMethod · 0.85
mainFunction · 0.85
demoFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 4

__sleep0Function · 0.85
create_futureMethod · 0.45
call_laterMethod · 0.45
cancelMethod · 0.45

Tested by 3

test_selectorMethod · 0.68
coroMethod · 0.68
doitMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…