[issue5162] multiprocessing cannot spawn child from a Windows service
Marc Schlaich added the comment: This issue is not fully fixed, there are some occasions where you can still run into it. One example is if you want to spawn a new multiprocessing.Process as sub process in a multiprocessing.Process: pythonservice.exe - multiprocessing.Process - multiprocessing.Process (does not start!) In this case you get: WINSERVICE: False WINEXE: False _python_exe: C:\Python27\python.exe prep data: {'authkey': '...', 'sys_path': [...], 'name': 'test', 'orig_dir': '...', 'sys_argv': ['C:\\Python27\\lib\\site-packages\\win32\\PythonService.exe'], 'main_path': 'C:\\Python27\\lib\\site-packages\\win32\\PythonService.exe', 'log_to_stderr': False} -- nosy: +schlamar ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Changes by Brian Curtin br...@python.org: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Changes by Antoine Pitrou pit...@free.fr: -- components: +Windows nosy: +brian.curtin, tim.golden versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Changes by Antoine Pitrou pit...@free.fr: -- stage: test needed - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Brian Curtin br...@python.org added the comment: This looks reasonable to me. If no one beats me to it, I'll check it in tonight. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Roundup Robot devnull@devnull added the comment: New changeset 1f41b1ab8924 by brian.curtin in branch '3.1': Fix #5162. Allow child spawning from Windows services (via pywin32). http://hg.python.org/cpython/rev/1f41b1ab8924 New changeset 184ae02e3221 by brian.curtin in branch '3.2': Fix #5162. Allow child spawning from Windows services (via pywin32). http://hg.python.org/cpython/rev/184ae02e3221 New changeset 3c2bdea18b5c by brian.curtin in branch 'default': Fix #5162. Allow child spawning from Windows services (via pywin32). http://hg.python.org/cpython/rev/3c2bdea18b5c New changeset 6507a5ba5c27 by brian.curtin in branch '2.7': Fix #5162. Allow child spawning from Windows services (via pywin32). http://hg.python.org/cpython/rev/6507a5ba5c27 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Brian Curtin br...@python.org added the comment: Thanks for the patch! -- assignee: jnoller - brian.curtin resolution: - fixed stage: patch review - committed/rejected ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Roundup Robot devnull@devnull added the comment: New changeset a280672d3d8d by brian.curtin in branch '2.7': Add NEWS item for #5162. http://hg.python.org/cpython/rev/a280672d3d8d -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Roundup Robot devnull@devnull added the comment: New changeset c26474c6504a by brian.curtin in branch '3.1': Add NEWS item for #5162. http://hg.python.org/cpython/rev/c26474c6504a New changeset 68ef2bf1aa99 by brian.curtin in branch '3.2': Add NEWS item for #5162. http://hg.python.org/cpython/rev/68ef2bf1aa99 New changeset 2c4043070f05 by brian.curtin in branch 'default': Add NEWS item for #5162. http://hg.python.org/cpython/rev/2c4043070f05 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Mher Movsisyan mher.movsis...@gmail.com added the comment: Attached test case demonstrates the issue. -- nosy: +mher Added file: http://bugs.python.org/file20240/test_issue5162.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Mher Movsisyan mher.movsis...@gmail.com added the comment: Treating python services like frozen executables solves the issue. The patch is attached. -- Added file: http://bugs.python.org/file20241/forking_r87679.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Changes by Mark Lawrence breamore...@yahoo.co.uk: -- versions: +Python 2.7, Python 3.1, Python 3.2 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Changes by Jesse Noller jnol...@gmail.com: -- priority: - normal ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
Changes by Daniel Diniz aja...@gmail.com: -- assignee: - jnoller keywords: +patch stage: - test needed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5162] multiprocessing cannot spawn child from a Windows service
New submission from Volodymyr Orlenko orle...@gmail.com: I think I've found a small bug with multiprocessing package on Windows. If you try to start a multiprocessing.Process from a Python- based Windows service, the child process will fail to run. When running the parent process as a regular Python program, everything works as expected. I've tracked the problem down to how main_path is prepared in multiprocessing.forking.get_preparation_data() (lines 370-377): def get_preparation_data(name): [...skipped a few lines...] if not WINEXE: main_path = getattr(sys.modules['__main__'], '__file__', None) if not main_path and sys.argv[0] not in ('', '-c'): main_path = sys.argv[0] if main_path is not None: if not os.path.isabs(main_path) and \ process.ORIGINAL_DIR is not None: main_path = os.path.join(process.ORIGINAL_DIR, main_path) d['main_path'] = os.path.normpath(main_path) return d When the program is running as a Windows service, but is not packaged into a single executable, main_path will become the path to the service executable (typically, pythonservice.exe). When this data makes it to the child process, the prepare() function will treat main_path as a path to a python module, and will try to import it. This causes it to fail. My quick-and-dirty solution was to check in get_preparation_data() if main_path ends with '.exe', and if it does, to not pass it at all. This solves the problem in my case, but perhaps there's a better way to fix this? Here is my version of get_preparation_data(): def get_preparation_data(name): ''' Return info about parent needed by child to unpickle process object ''' from .util import _logger, _log_to_stderr d = dict( name=name, sys_path=sys.path, sys_argv=sys.argv, log_to_stderr=_log_to_stderr, orig_dir=process.ORIGINAL_DIR, authkey=process.current_process().authkey, ) if _logger is not None: d['log_level'] = _logger.getEffectiveLevel() if not WINEXE: main_path = getattr(sys.modules['__main__'], '__file__', None) if not main_path and sys.argv[0] not in ('', '-c'): main_path = sys.argv[0] if main_path is not None: if not os.path.isabs(main_path) and \ process.ORIGINAL_DIR is not None: main_path = os.path.join(process.ORIGINAL_DIR, main_path) if not main_path.endswith('.exe'): d['main_path'] = os.path.normpath(main_path) return d -- components: Library (Lib) files: forking-patch messages: 81247 nosy: jnoller, orlenko severity: normal status: open title: multiprocessing cannot spawn child from a Windows service type: behavior versions: Python 2.6 Added file: http://bugs.python.org/file12949/forking-patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5162 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com