Commit 4e02f8f8 authored by Steve Dower's avatar Steve Dower Committed by GitHub

bpo-35797: Fix default executable used by the multiprocessing module (GH-11676)

parent 3bab40db
......@@ -29,12 +29,19 @@ __all__ = ['_main', 'freeze_support', 'set_executable', 'get_executable',
if sys.platform != 'win32':
WINEXE = False
WINSERVICE = False
_WINENV = False
else:
WINEXE = (sys.platform == 'win32' and getattr(sys, 'frozen', False))
WINEXE = getattr(sys, 'frozen', False)
WINSERVICE = sys.executable.lower().endswith("pythonservice.exe")
_WINENV = '__PYVENV_LAUNCHER__' in os.environ
if WINSERVICE:
_python_exe = os.path.join(sys.exec_prefix, 'python.exe')
elif _WINENV:
# bpo-35797: When running in a venv, we need to bypass the redirect
# executor and launch our base Python.
import _winapi
_python_exe = _winapi.GetModuleFileName(0)
else:
_python_exe = sys.executable
......
......@@ -306,6 +306,19 @@ class BasicTest(BaseTest):
)
self.assertEqual(out.strip(), '0')
def test_multiprocessing(self):
"""
Test that the multiprocessing is able to spawn.
"""
rmtree(self.env_dir)
self.run_with_capture(venv.create, self.env_dir)
envpy = os.path.join(os.path.realpath(self.env_dir),
self.bindir, self.exe)
out, err = check_output([envpy, '-c',
'from multiprocessing import Pool; ' +
'print(Pool(1).apply_async("Python".lower).get(3))'])
self.assertEqual(out.strip(), "python".encode())
@skipInVenv
class EnsurePipTest(BaseTest):
"""Test venv module installation of pip."""
......
Fix default executable used by the multiprocessing module
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment