mirror of
https://github.com/python/cpython.git
synced 2025-11-01 14:11:41 +00:00
bpo-46720: Add support for path-like objects to multiprocessing.set_executable for Windows (GH-31279)
This bring the API to be on a par with Unix-like systems.
This commit is contained in:
parent
f912cc0e41
commit
5576ddbbbc
5 changed files with 34 additions and 8 deletions
|
|
@ -33,18 +33,21 @@
|
|||
WINEXE = getattr(sys, 'frozen', False)
|
||||
WINSERVICE = sys.executable.lower().endswith("pythonservice.exe")
|
||||
|
||||
if WINSERVICE:
|
||||
_python_exe = os.path.join(sys.exec_prefix, 'python.exe')
|
||||
else:
|
||||
_python_exe = sys.executable
|
||||
|
||||
def set_executable(exe):
|
||||
global _python_exe
|
||||
_python_exe = exe
|
||||
if sys.platform == 'win32':
|
||||
_python_exe = os.fsdecode(exe)
|
||||
else:
|
||||
_python_exe = os.fsencode(exe)
|
||||
|
||||
def get_executable():
|
||||
return _python_exe
|
||||
|
||||
if WINSERVICE:
|
||||
set_executable(os.path.join(sys.exec_prefix, 'python.exe'))
|
||||
else:
|
||||
set_executable(sys.executable)
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
|
@ -86,7 +89,8 @@ def get_command_line(**kwds):
|
|||
prog = 'from multiprocessing.spawn import spawn_main; spawn_main(%s)'
|
||||
prog %= ', '.join('%s=%r' % item for item in kwds.items())
|
||||
opts = util._args_from_interpreter_flags()
|
||||
return [_python_exe] + opts + ['-c', prog, '--multiprocessing-fork']
|
||||
exe = get_executable()
|
||||
return [exe] + opts + ['-c', prog, '--multiprocessing-fork']
|
||||
|
||||
|
||||
def spawn_main(pipe_handle, parent_pid=None, tracker_fd=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue