blocking-input-in-async-function (ASYNC250)
Derived from the flake8-async linter.
This rule is unstable and in preview. The --preview
flag is required for use.
What it does
Checks that async functions do not contain blocking usage of input from user.
Why is this bad?
Blocking an async function via a blocking input call will block the entire event loop, preventing it from executing other tasks while waiting for user input, negating the benefits of asynchronous programming.
Instead of making a blocking input call directly, wrap the input call in an executor to execute the blocking call on another thread.
Example
Use instead: