Grokking Concurrency in Python
Vote

0% completed

​

How Web Frameworks Use Threads

Two FastAPI endpoints can contain the same blocking database query and differ in a single word: one is declared with def, and the other with async def. The framework runs the first in a worker thread and the second on the event loop itself. Under load, the def version lets other requests continue, while the async def version makes every request on the server wait behind it. The def version also has a limit that no line of the application sets.

Two Kinds of Endpoint

FastAPI is built on Starlette, and both run on an ASGI server such as uvicorn

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content