Skip to content
Preptima
mediumConceptCodingMidSenior

The same multiprocessing code runs fine on your Linux box and breaks on a colleague's Mac. What is different?

Python multiprocessing behaves differently across platforms because fork inherits parent memory while spawn starts a fresh interpreter, re-imports the module and requires picklable callables and arguments. It also connects start methods to the point an interviewer is testing.

4 min readUpdated 2026-08-15Target archetype: Big Tech, Enterprise Captive, Product Startup

Answer

Short answer

The difference is the start method. Linux code often relies on fork inheriting globals, while macOS and Windows commonly use spawn, which re-imports the module and pickles work, so code needs a main guard and explicit, picklable inputs.

Was this answer helpful?

Likely follow-ups

  • Why does forking a process that already has threads risk a deadlock in the child?
  • What does forkserver give you that neither fork nor spawn does?
  • How would you share a large read-only array with workers without pickling a copy per worker?
  • Why must set_start_method be called only once, and where should that call live?

Related questions

Further reading

Related Topics