FASTAPI Async def vs Def

Can someone explain to me why Fastapi recommends not to use async def in blocking I/O operations in detail? I've searched online but couldn't find a single explanation that had all the details.

1 answer

  • answered 2021-09-11 18:08 Alen Paul Varghese

    quoting python-doc

    Blocking (CPU-bound) code should not be called directly. For example, if a function performs a CPU-intensive calculation for 1 second, all concurrent asyncio Tasks and IO operations would be delayed by 1 second.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum