Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
How async/await works in Python (tenthousandmeters.com)
37 points by r4victor on Sept 4, 2021 | hide | past | favorite | 5 comments


Hi! 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/

As always, I welcome your feedback and questions. Thanks!


Fantastic read thank you very much!

It's really hard to find in depth articles like this nowadays.


Interesting 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 while still trying to wrap my head around redux-saga https://redux-saga.js.org/)

Haven’t done python for a while; was ‘t aware js & python share such resemblances!


Thanks, 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?


you lost me at "subgenerators"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: