3 ms·
How async/await works in Python
- r4victor 5y agoHi! I'm the author of this post. I've been writing asynchronous Python code with async/await for quite a while but didn't have a perfect understanding of how it actually works: what await does; what an event loop really is and how it runs coroutines; what coroutines are; why Python has native coroutines as well as generator-based coroutines; how asyncio works; and so forth... In this post I've tried to answer all these questions. After reading it, you should be able to reason about async/await code almost as easily as you reason about regular Python code. If you liked this post, you may also like other posts in my Python behind the scenes series: https://tenthousandmeters.com/tag/python-behind-the-scenes/ https://tenthousandmeters.com/tag/python-behind-the-scenes/ As always, I welcome your feedback and questions. Thanks!
- rudasn 5y agoFantastic read thank you very much! It's really hard to find in depth articles like this nowadays.
- archibaldJ 5y agoInteresting to see this language feature being broken down in python. Just today I was looking at async/await & generator in js (and wrote a summary here https://stackoverflow.com/a/69055066 https://stackoverflow.com/a/69055066 while still trying to wrap my head around redux-saga https://redux-saga.js.org/ https://redux-saga.js.org/) Haven’t done python for a while; was ‘t aware js & python share such resemblances!
- aiNohY6g 5y agoThanks, super interesting read! Side note: I've been desperately looking for a simple, clear and practical "getting started" guide of async/await in python. Any link you can recommend?
- mcc1ane 5y agoyou lost me at "subgenerators"