Exercise: Fetch All

A page needs data from several URLs. Fetching them one at a time wastes time waiting. Fetch them all at once.

fetch_all gets a list of URLs and an async fetch function. It is passed in, as in the fakes lesson, so the tests can use a fake that counts how many fetches are running at the same moment.

Exercise: write fetch_all so it fetches every URL concurrently and returns the results in the same order as urls. A loop that awaits each fetch in turn gives the right results but fails the concurrency test.

Hint: build a list of coroutines, then await asyncio.gather(*coros). The * spreads the list into separate arguments.

Press Check to run the tests.