New submission from Paul Moore <p.f.mo...@gmail.com>:
If I run the following sample program using Python 3.7.3 (64 bit) for Windows, it immediately fails, producing a massive traceback. import multiprocessing def f(n): return n+1 with multiprocessing.Pool() as p: for n in p.map(f, [1,2,3]): print(n) This is a part of the traceback produced - the whole traceback seemed to be continually increasing, until I killed (some of) the python processes via task manager: Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 105, in spawn_main exitcode = _main(fd) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 114, in _main prepare(preparation_data) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 225, in prepare _fixup_main_from_path(data['init_main_from_path']) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path run_name="__mp_main__") File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 263, in run_path pkg_name=pkg_name, script_name=fname) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 96, in _run_module_code Traceback (most recent call last): File "<string>", line 1, in <module> mod_name, mod_spec, pkg_name, script_name) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 105, in spawn_main File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code exitcode = _main(fd) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 114, in _main exec(code, run_globals) prepare(preparation_data) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 225, in prepare File "C:\Work\Scratch\t.py", line 6, in <module> _fixup_main_from_path(data['init_main_from_path']) with multiprocessing.Pool() as p: File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\context.py", line 119, in Pool run_name="__mp_main__") File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 263, in run_path context=self.get_context()) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\pool.py", line 176, in __init__ pkg_name=pkg_name, script_name=fname) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 96, in _run_module_code mod_name, mod_spec, pkg_name, script_name) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code self._repopulate_pool() exec(code, run_globals) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\pool.py", line 241, in _repopulate_pool File "C:\Work\Scratch\t.py", line 6, in <module> with multiprocessing.Pool() as p: w.start() File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\context.py", line 119, in Pool File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 112, in start context=self.get_context()) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\pool.py", line 176, in __init__ self._popen = self._Popen(self) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\context.py", line 322, in _Popen self._repopulate_pool() File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\pool.py", line 241, in _repopulate_pool return Popen(process_obj) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\popen_spawn_win32.py", line 46, in __init__ w.start() File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\process.py", line 112, in start prep_data = spawn.get_preparation_data(process_obj._name) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 143, in get_preparation_data self._popen = self._Popen(self) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\context.py", line 322, in _Popen return Popen(process_obj) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\popen_spawn_win32.py", line 46, in __init__ _check_not_importing_main() File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main prep_data = spawn.get_preparation_data(process_obj._name) File "C:\Users\pmoore\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 143, in get_preparation_data is not going to be frozen to produce an executable.''') RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. This probably means that you are not using fork to start your child processes and you have forgotten to use the proper idiom _check_not_importing_main() in the main module: if __name__ == '__main__': freeze_support() ---------- components: Library (Lib), Windows messages: 338870 nosy: paul.moore, steve.dower, tim.golden, zach.ware priority: high severity: normal status: open title: multiprocessing crashes in Python 3.7.3 on Windows type: behavior versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36435> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com