Content-Length: 33121 | pFad | https://docs.astral.sh/ruff/rules/long-sleep-not-forever/

long-sleep-not-forever (ASYNC116) | Ruff
Skip to content

long-sleep-not-forever (ASYNC116)

Derived from the flake8-async linter.

Fix is sometimes available.

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

What it does

Checks for uses of trio.sleep() or anyio.sleep() with a delay greater than 24 hours.

Why is this bad?

Calling sleep() with a delay greater than 24 hours is usually intended to sleep indefinitely. Instead of using a large delay, trio.sleep_forever() or anyio.sleep_forever() better conveys the intent.

Example

import trio


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

Use instead:

import trio


async def func():
    await trio.sleep_forever()

Fix safety

This fix is marked as unsafe as it changes program behavior.









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://docs.astral.sh/ruff/rules/long-sleep-not-forever/

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy