runtime
378 / 500
question 378 Threading & Multiprocessing · medium

Check jobs before sending them to processes

A batch system sends jobs to a process pool, and a job that can't be pickled fails only after the pool has started. Write a pre-flight check unsendable(jobs) that tries to pickle each job and returns the positions of the ones that can't be sent.

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

Functionunsendable(jobs)
Returnsa list of the indexes of jobs for which pickle.dumps raises, in order
Rulecatch the errors pickling raises for such objects (pickle.PicklingError, TypeError, AttributeError); don't stop at the first failure

Loading your progress…

Check jobs before sending them to processes — Python practice · Runtime