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.
Asked
Active
Viewed 740 times
1

Chris
- 18,724
- 6
- 46
- 80

Diogo Crava
- 21
- 5
1 Answers
0
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.

Alen Paul Varghese
- 1,278
- 14
- 27