Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Parallel Fetching With Three Paradigms

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Parallel Fetching With Three Paradigms. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Task #2: Implement a data fetching service that runs three parallel asynchronous fetches and collects results using three distinct concurrency paradigms: callback-based (DispatchGroup), Combine publisher-based (MergeMany/collect), and Structured Concurrency (withTaskGroup).

Asked in the First Technical Assessment (Timed Debugging Test) stage. This was a 90-minute timed assignment, and Stack Overflow or forum searches were prohibited.

Implement the Python function below so it models the same behavior for three fetches: run them in parallel, collect successful results, and return "error" immediately if any fetch fails.

Function

def fetch_three_results(fetches):

Input

fetches: a list of exactly 3 values, each either a string result or the string "error".

Output

Return a list of the three successful results in completion order, or the string "error" if any fetch fails.

Constraints

  • len(fetches) == 3
  • Each element of fetches is a string
  • A value of "error" represents a failed fetch
  • No additional metadata is provided

Function Signature

def fetch_three_results(fetches):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output