Creating Coroutines, Events, and Message-Driven Transactions
The FastAPI framework is an asynchronous framework that runs over the asyncio platform, which utilizes the ASGI protocol. It is well known for its 100% support for asynchronous endpoints and non-blocking tasks. This chapter will focus on how we create highly scalable applications with asynchronous tasks and event-driven and message-driven transactions.
We learned in Chapter 2, Exploring the Core Features, that Async/Await or asynchronous programming is a design pattern that enables other services or transactions to run outside the main thread. The framework uses the async
keyword to create asynchronous processes that will run on top of other thread pools and will be awaited, instead of invoking them directly. The number of external threads is defined during the Uvicorn server startup through the --worker
option.
In this chapter, we will delve into the framework and scrutinize the various components of the FastAPI Framework...