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)
| 671 | |
| 672 | |
| 673 | def 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 | |
| 694 | class _NullFuture: |
nothing calls this directly
no test coverage detected