Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.
Start 7-day trial →
⚡
← Courses
›
Interview Prep
›
Module 6 · Concurrency, OS, ML Interview Topics
›
asyncio.gather vs as_completed
quiz
87 / 104
🇺🇸
EN
▼
↗
Share
⋯
More
+100 XP
📋
Task
📖
Theory
🤖
AI Help
Task
📝 **Question:** Fetch 100 URLs in parallel, take first 5 to finish? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
🎯 Quiz
Question
📝 **Question:** Fetch 100 URLs in parallel, take first 5 to finish? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
A
`await asyncio.gather(*coros)` and slice `[:5]` — gather preserves submission order so the first five complete first.
B
`as_completed` with a counter — yields in completion order; break after 5.
C
Loop `await coro` sequentially with a counter — five sequential awaits is the canonical pattern for partial concurrency.
D
Not possible in asyncio — asyncio requires every awaited coroutine to finish before any result is returned to the caller.
Submit answer
💬 Discussion
Be the first to ask a question or share a tip.
Sign in
to join the discussion. Reading is free.
Loading discussion…