Grokking Concurrency in Python
Vote

0% completed

​

One Blocking Call Stops Everything

time.sleep(SAVE_TIME) # stands for a blocking database write

That one line sits inside an async def function in Harvest's fetcher. With await asyncio.sleep(SAVE_TIME) in its place, eight pages took 0.36 seconds to fetch and save. With time.sleep, the same eight pages took 1.06 seconds, and a small task that should wake up every 10 milliseconds was once 0.39 seconds late. Nothing crashed, and no error appeared in the log. Every task simply became slower at the same time.

One Thread Runs Every Task

An asyncio program runs all of its tasks on one thread

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content