Skip to main content

Practice ยท 2 of 2

Pair Results with Inputs

Implement async def fetch_name(user_id) awaiting sleep(0.02) and returning f'user-{user_id}'. Implement async def collect(pairs) where pairs is a list of (key, user_id) tuples: run all fetches concurrently and return a dict key -> fetched name. Provide sync wrapper run_collect(pairs).

Difficulty: intermediate

Back to lesson: Practice: Task Concurrency Drills