MCPcopy
hub / github.com/tornadoweb/tornado / sleep

Function sleep

tornado/gen.py:673–691  ·  view source on GitHub ↗

Return a `.Future` that resolves after the given number of seconds. When used with ``yield`` in a coroutine, this is a non-blocking analogue to `time.sleep` (which should not be used in coroutines because it is blocking):: yield gen.sleep(0.5) Note that calling this functi

(duration: float)

Source from the content-addressed store, hash-verified

671
672
673def sleep(duration: float) -> "Future[None]":
674 """Return a `.Future` that resolves after the given number of seconds.
675
676 When used with ``yield`` in a coroutine, this is a non-blocking
677 analogue to `time.sleep` (which should not be used in coroutines
678 because it is blocking)::
679
680 yield gen.sleep(0.5)
681
682 Note that calling this function on its own does nothing; you must
683 wait on the `.Future` it returns (usually by yielding it).
684
685 .. versionadded:: 4.1
686 """
687 f = _create_future()
688 IOLoop.current().call_later(
689 duration, lambda: future_set_result_unless_cancelled(f, None)
690 )
691 return f
692
693
694class _NullFuture:

Callers

nothing calls this directly

Calls 4

_create_futureFunction · 0.85
call_laterMethod · 0.80
currentMethod · 0.80

Tested by

no test coverage detected