1

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.

Chris
  • 18,724
  • 6
  • 46
  • 80

1 Answers1

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