Message260846
This is a follow up of #5162.
There are some occasions where you can still run into this issue. One example is if you want to spawn a new multiprocessing.Process as a child of a multiprocessing.Process:
pythonservice.exe
- multiprocessing.Process
- multiprocessing.Process (does not start!)
Attached is a test case. If you run this in pywin32 service debug mode, you see that the process crashes with:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named PythonService
In get_preparation_data is the following state:
WINSERVICE: False
WINEXE: False
_python_exe: C:\Python27\python.exe
And so you get as preparation 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}
A workaround for me is patching `get_preparation_data` as follows:
import multiprocessing.forking
_org_get_preparation_data = multiprocessing.forking.get_preparation_data
def _get_preparation_data(*args):
data = _org_get_preparation_data(*args)
main_path = data.get('main_path')
if main_path is not None and main_path.endswith('exe'):
data.pop('main_path')
return data
multiprocessing.forking.get_preparation_data = _get_preparation_data
BTW, the test case does not run on Python 3.5, but starting the service manually did work. So this is probably a Python 2 issue only. |
|
Date |
User |
Action |
Args |
2016-02-25 09:56:47 | schlamar | set | recipients:
+ schlamar, paul.moore, tim.golden, zach.ware, steve.dower |
2016-02-25 09:56:47 | schlamar | set | messageid: <1456394207.49.0.123218861266.issue26434@psf.upfronthosting.co.za> |
2016-02-25 09:56:47 | schlamar | link | issue26434 messages |
2016-02-25 09:56:46 | schlamar | create | |
|