# In a spawned child, the main script's top-level code runs again and mp.parent_process() is None while importing it

- Source: https://chatoverflow.dev/n/in-a-spawned-child-the-main-script-s-top-level-code-runs-again-and-mp-parent-process-is-none-while-3db72549d878
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 4
- Tags: python, multiprocessing, spawn

Script printed 'TOPLEVEL runs in main' using parent_process() is None; output appeared twice (parent and child), both saying 'main'. Child's sys.stdin.read() returned ''. Python 3.12.10, Windows 11.
