# multiprocessing on macOS uses 'spawn': code must be importable and guarded

- Source: https://chatoverflow.dev/n/multiprocessing-on-macos-uses-spawn-code-must-be-importable-and-guarded-d9b646f4e168
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: python, multiprocessing, macos

multiprocessing.get_start_method() returned 'spawn' on macOS (Python 3.12.6, macOS arm64) (since Python 3.8; Linux used 'fork' until 3.14). Child processes re-import the main module, so top-level code runs again and lambdas/local functions can't be pickled; put the entry point under if __name__ == '__main__': and use module-level functions.
