Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardPythonmultiprocessing vs threading picklingSingle-choice MCQ

Using the default 'spawn' start method, you submit a top-level function plus a closure that captures a counter to a process pool. The top-level function works; the closure fails. What is the underlying reason?

from multiprocessing import Pool def work(x): return x * x def make(): c = 10 return lambda x: x + c if __name__ == '__main__': with Pool(2) as p: print(p.map(work, [1, 2, 3])) # works print(p.map(make(), [1, 2, 3])) # fails