Skip to content
C

Concurrent Async Tasks

Mediumpython

Write an asyncio program that "fetches" n items concurrently (each using asyncio.sleep), and report whether the total runtime shows they ran concurrently.

Approach: define an async fetch_item coroutine, run n of them together with asyncio.gather(), time the whole thing, and classify the result the same way as the threading problem — a classification rather than a raw timing value.

Input: One line: the number of items to "fetch", n.

Output: Two lines: "Fetched <n> items", then "Concurrent" if they clearly ran together, or "Sequential" otherwise.

Input (stdin)

Output

Run your code to see output here...