Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Lib/multiprocessing/spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@
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

Expand Down
13 changes: 13 additions & 0 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,19 @@ def test_unicode_in_batch_file(self):
)
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."""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix default executable used by the multiprocessing module