async-function-with-timeout (ASYNC109)#
Derived from the flake8-async linter.
What it does#
Checks for async functions with a timeout argument.
Why is this bad?#
Rather than implementing asynchronous timeout behavior manually, prefer
built-in timeout functionality, such as asyncio.timeout, trio.fail_after,
or anyio.move_on_after, among others.
Example#
Use instead:
async def long_running_task(): ...
async def main():
async with asyncio.timeout(2):
await long_running_task()