Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Multi-Threaded Task Manager
00:00
5 left

Multi-Threaded Task Manager

HardPython

Problem

Implement a multi threaded task manager.

The manager receives tasks with dependencies, priorities, retry limits, and deterministic failure settings. Execute independent tasks concurrently, schedule ready tasks by priority, retry failures when allowed, and mark descendants as blocked when a dependency permanently fails.

Input: tasks, a list of dictionaries containing id, dependencies, priority, retries, and fail_until, plus worker_count. Output: a dictionary mapping each task ID to its final status and number of attempts. Valid inputs contain unique IDs, known dependencies, and an acyclic dependency graph.

Example: task b depending on successful task a finishes after a. If a permanently fails, b is blocked.

Constraints

  • 1 <= len(tasks) <= 1000
  • 1 <= worker_count <= 64
  • Task IDs are unique strings
  • Every dependency refers to a task ID
  • The dependency graph is acyclic
  • priority is an integer
  • retries and fail_until are non-negative integers
  • A task may execute only after all dependencies succeed

Function Signature

def execute_task_manager(tasks, worker_count):
Interviewer

Your question is Multi-Threaded Task Manager. Start with the requirements in the Question tab.

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.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.