runtime
380 / 500
question 380 Threading & Multiprocessing · hard

Retry failed jobs through an executor

A geocoding service fails now and then. Write run_with_retries(executor, func, items, attempts): submit every item, collect results, then resubmit only the items that failed, up to attempts rounds in total. Return (results, failed): results for every item that eventually worked, and the sorted items that failed in every round.

Read and diagnose: this can't run in the browser, so you'll read real code and output and answer questions about it.

Functionrun_with_retries(executor, func, items, attempts)
Roundsround 1 submits every item; each later round submits only the items whose latest attempt raised; at most attempts rounds
Returns(results, failed): a dictionary item → result, and a sorted list of items that never succeeded
Rulewithin a round, submit every item before reading any result

Loading your progress…

Retry failed jobs through an executor — Python practice · Runtime