This text is a part of my ongoing FastAPI 101 series. In my earlier article I spoke about what FastAPI is, knowledge sorts and Pydantic.
This chapter may have little or no code, we’ll overview a core idea for APIs — async and await — that is so vital that I might fairly we make certain to totally perceive the idea earlier than we create our first API undertaking (spoiler of subsequent article).
Asynchronous code is a approach to inform your program, in some unspecified time in the future within the code, that it should look forward to one thing else to complete some place else. Your program will come again each time it has an opportunity as a result of it’s ready once more or at any time when it completed all of the work it had at that time.
As soon as your program finishes a process, it takes the primary subsequent process to complete and continues no matter it needed to do with it.
That “look forward to one thing else” usually refers to I/O operations which are comparatively “gradual” (in comparison with the pace of the processor and the RAM reminiscence).