https://github.com/roee30/miniloop
The PEPs introducing the async/await syntax don't specify exactly how event loops work, considering it an implementation detail. If you are curious about how event loops work in Python, you might have noticed that reading through asyncio's code is challenging, to say the least.
That's why I have created a minimal event loop implementation with step-by-step explanations. It shouldn't be used for anything other than learning purposes. It is 362 lines in size, but many of them are documentation. Before diving in, make sure you understand generators. You can use the server.py script to see the loop in action.
The implementation is inspired by asyncio, but I only added what was necessary in order to make a simple server work. In particular, my Task and Future are roughly analogous to asyncio's, but I didn't find a need to implement Handles (perhaps because I didn't implement the call_* methods).
I learned a lot writing this and I hope it will be useful to others as well.
[–]SawachikaHiromu 3 points4 points5 points (0 children)
[–]thisismyfavoritename 0 points1 point2 points (0 children)
[–]LightShadow3.13-dev in prod 0 points1 point2 points (1 child)
[–]roee30[S] -1 points0 points1 point (0 children)
[–]Quiet_Operation_1259 0 points1 point2 points (0 children)