Skip to content
CampusEduX

Concurrent Async Tasks

Mediumpython
Learn the Concept: Concurrency & Performance

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.

Related Problems

  • Concurrent Downloads with Threading
    Medium · python
    Solve Problem
  • Parallel Square Calculation with Multiprocessing
    Medium · python
    Solve Problem
  • Cache a Slow Fibonacci with lru_cache
    Medium · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...