def checkpoint():
"""A pure :ref:`checkpoint <checkpoints>`.
This checks for cancellation and allows other tasks to be scheduled,
without otherwise blocking.
Note that the scheduler has the option of ignoring this and continuing to
run the current task if it decides this is appropriate (e.g. for increased
efficiency).
Equivalent to ``await trio.sleep(0)`` (which is implemented by calling
:func:`checkpoint`.)
"""
with open_cancel_scope(deadline=-inf) as scope:
await _core.wait_task_rescheduled(lambda _: _core.Abort.SUCCEEDED)
评论列表
文章目录