← Quiz: Threads, Processes and the GIL: all 10 questions
Quiz: Threads, Processes and the GIL · Question 9 of 10
Why must ProcessPoolExecutor code be inside if name == "main": on Windows?
Why must ProcessPoolExecutor code be inside if __name__ == "__main__": on Windows?
- A.Otherwise the processes cannot return values
- B.It makes the processes faster
- C.New processes re-import the file, and without the guard they would start new pools again
- D.Windows does not support processes otherwise
Answer & explanation
Correct answer: New processes re-import the file, and without the guard they would start new pools again
The guard makes sure only the original program creates the pool.
Can you get the rest right without peeking?
Take the timed Quiz: Threads, Processes and the GIL quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →