Skip to content

trio-zero-sleep-call (TRIO115)#

Derived from the flake8-trio linter.

Fix is always available.

This rule is unstable and in preview. The --preview flag is required for use.

What it does#

Checks for uses of trio.sleep(0).

Why is this bad?#

trio.sleep(0) is equivalent to calling trio.lowlevel.checkpoint(). However, the latter better conveys the intent of the code.


async def func():
    await trio.sleep(0)

Use instead:

async def func():
    await trio.lowlevel.checkpoint()