Have you ever ordered something from Starbucks? Like most other businesses, it is primarily interested in maximising the number of orders fulfilled, and that’s why they use asynchronous processing: when you ask for your coffee, the cashier marks a cup with your order and places it into a queue. Queuing orders decouples cashiers and baristas, allowing the cashier to keep taking orders and the deployment of many baristas at peak times. At scale, it would be absurd to see a cashier taking an order and fulfilling it before moving on with the next customer. Yet, we often rely on very similar strategies when we code.
Asynchronous programming has become a huge hit, and there are two main reasons for it. First, it mitigates the problems of systems that make multiple external requests to serve one incoming request (fan-out), making them way faster. And second, it helps save money on infrastructure by using resources better.
However, many Python developers, while intrigued, are intimidated by this programming paradigm, and so the goal of this talk is to help figure out how the heck all of this works. In order to do so, what I’m going to do is to review how async was incorporated into Python using the building blocks that all Python developers are already familiar with, such as iterators and generator expressions.
We will use that foundation to dive into coroutines, the yield from syntax, and finally, async/await. At the end of the talk, we may build a simple web-crawler using what we’ve learnt, and understand the internals of async web services such as Starlette or aiohttp.
What do you need to know to enjoy this talk
Python level
Medium knowledge: You use frameworks and third-party libraries.
About the topic
No previous knowledge of the topic is required, basic concepts will be explained.