flâneur — a map of the web's best reading

Asyncio Explainer Notebook - Colab

colab.research.google.com · 4 words · saved by 1 readers

So we define them to return a function which is defined using the async def keyword. Normally, when we define and run functions (without using async), functions get in a long queue and only start executing when the functions before it in the queue are finished. Imagine this like a single-lane highway, where every car has to wait for the car in front of it before it can drive. The asyncio library lets the code run like a "multi-lane highway", so if one function takes a long time, the other functions can "switch lanes" and continue to execute while the program waits for the slow-moving function to finish executing. The asyncio library refers to this scheduling mechanism as an "event loop". When we define a function using async def this lets asyncio know that other functions can be run in parallel with this function in the event loop; asyncio won't let other functions run at the same time if we define a function normally (i.e. just using the def keyword). When we make calls to LLM APIs (o

Google Colab Sign in

Explore this link on the map →

related reading