Ever wondered what's going in with async
/await
?
A long while back, I was confused by when using asynchronous programming in python - how can it even be that you need a library (the asyncio
library) to use a function declared with nothing but python native keywords?
I did understand how to use async
and await
in the context of a framework, but I felt like I was missing something. I couldn't seem to find a satisfying explanation of how async
/await
and asyncio
work.
I also couldn't find any blog posts that helped.
Once I finally felt I got the hang of it (not too long ago!), I decided to write a series of posts to explain the topic.
Why a series?
I'm writing a series of posts instead of a standalone blog post. And it will be a long series. I plan to start a long way from the asynchronous coroutine. I'm going to cover sequences, iterables and iterators, generators (a special kind of iterator), generator based coroutines, and finally, the awaitable coroutine. And let's not forget "magic methods" (also called "dunder methods").
There is a reason for this. To explain how a the awaitable coroutine works, I want to mention - and explain - a lot of concepts, starting rather simple, so (hopefully) anyone can understand async
/await
just by reading the series. By starting with relatively simple constructs (constructs that gave rise to the awaitable coroutine), I am able to introduce these concepts much slower, and thereby, more digestible.
Prerequisites
Before reading this series, you should probably be
- familiar with Python, or at least another programming language
- familiar with classes, including the Python kind, where you pass around
self
all the time.
Now that I've explained the topic and the motivation, let's begin!
Top comments (0)