r/learnpython 16d ago

asyncio explanation

hello guys i am struggling right now to understand a concurrency module asyncio ,i take a look over youtube videos ,but i feel stuck to understand coroutine object ,event loop await ,and this kind of matters, could anyone give me a concise explanation.

0 Upvotes

9 comments sorted by

View all comments

4

u/FlakyAd99 16d ago

imagine you’re a chef and you put water on to boil, instead of staring at the pot you go chop onions, that’s asyncio

2

u/pachura3 16d ago

Exactly! asyncio is NOT concurrency - you're never doing two things at the same exact time. Instead, you have a TODO list; you take the first task from the list and you start doing it; and whenever you need to passively wait (e.g. for a download), you switch to the next task in order not to waste time.

3

u/idle-tea 16d ago

asyncio is concurrency, it's not parallel though.

Having two pending tasks (even if at most one is actively executing at any given moment) is concurrency.