← Backend PythonQuestion 4 of 49
What happens if you use the requests library inside an async def endpoint?
📘 Explanation
The requests library performs synchronous, blocking I/O, so calling it inside an async def endpoint freezes the entire event loop until the request completes, stopping all other async tasks from running. The fix is to use httpx.AsyncClient, which is designed for non-blocking async HTTP calls. It doesn't raise a RuntimeError, nor does it run concurrently or spawn a thread automatically—Python doesn't add that behavior for you.
Related questions
← PreviousNo login needed