Yes, I know, practice is important, but what’s a good place to start?
Is the book “Using Asyncio in Python” good?
Yes, I know, practice is important, but what’s a good place to start?
Is the book “Using Asyncio in Python” good?
I’ve no idea about that book specifically, but I would recommend first learning how threads work if you don’t already. You can mostly pretend that threads run truly simultaneously, though in practice, they mostly take turns. Using async/await is then very similar, except that the same task keeps running until it hits an await - it’s like taking turns, but you get to choose how long your turn is.
The best way to get to understand it is to have a project that uses it. That’s not just an async/await thing, that’s true of basically every technology ![]()
I mostly get threads.
I’ve inherited some code that uses python async.
I’ll probably want to do some sample programs with async.
Cool! Try to find where individual tasks get spawned; there’s probably somewhere that basically goes “okay, now spin off a task to do this” (like “handle this client” or something). That would be roughly equivalent to spawning a thread to do that job.
If you want to really understand async and await, then start with official Python docs and then watch a clear walkthrough on YouTube like the ones by Corey Schafer. After that, build a tiny project like an async web scraper using aiohttp. Nothing makes it click faster than seeing it run in your own code…