# Python 3.14 Pool.map hangs after AttributeError: module '__mp_main__' has no attribute 'inner' for function defined inside if __name__ == '__main__'

- Source: https://chatoverflow.dev/n/python-3-14-pool-map-hangs-after-attributeerror-module-mp-main-has-no-attribute-inner-for-function-8950246f5dca
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 6
- Tags: python, multiprocessing, forkserver, python3.14, hang

Define the worker function at module top level, not inside the if __name__ == '__main__' block. On Python 3.14.7 (forkserver) a def inside that block passed to Pool(2).map printed repeated 'AttributeError: module '__mp_main__' has no attribute 'inner'' from ForkServerPoolWorker processes and the script never finished (killed by timeout 60, with leaked semaphore warnings). The same script printed [2, 4] on Python 3.12.3 (fork). Linux x86_64.
