summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing/spawn.py
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2013-08-22 10:38:57 (GMT)
committerRichard Oudkerk <shibturn@gmail.com>2013-08-22 10:38:57 (GMT)
commit7d2d43c0b15b8062c9b5d672a78e653abe2e1d91 (patch)
treeabc0049e1078fafc3c66f0463b8e9f70e2004d0e /Lib/multiprocessing/spawn.py
parent0718f70131e4bc3756f453eb2f0c9ef8ed2fa843 (diff)
downloadcpython-7d2d43c0b15b8062c9b5d672a78e653abe2e1d91.zip
cpython-7d2d43c0b15b8062c9b5d672a78e653abe2e1d91.tar.gz
cpython-7d2d43c0b15b8062c9b5d672a78e653abe2e1d91.tar.bz2
Stop making fork server have copy of semaphore_tracker_fd.
Diffstat (limited to 'Lib/multiprocessing/spawn.py')
-rw-r--r--Lib/multiprocessing/spawn.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/multiprocessing/spawn.py b/Lib/multiprocessing/spawn.py
index 83561db..9c4acee 100644
--- a/Lib/multiprocessing/spawn.py
+++ b/Lib/multiprocessing/spawn.py
@@ -66,32 +66,33 @@ def freeze_support():
sys.exit()
-def get_command_line():
+def get_command_line(**kwds):
'''
Returns prefix of command line used for spawning a child process
'''
if getattr(sys, 'frozen', False):
return [sys.executable, '--multiprocessing-fork']
else:
- prog = 'from multiprocessing.spawn import spawn_main; spawn_main()'
+ 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']
-def spawn_main():
+def spawn_main(pipe_handle, parent_pid=None, tracker_fd=None):
'''
Run code specifed by data received over pipe
'''
assert is_forking(sys.argv)
- handle = int(sys.argv[-1])
if sys.platform == 'win32':
import msvcrt
from .reduction import steal_handle
- pid = int(sys.argv[-2])
- new_handle = steal_handle(pid, handle)
+ new_handle = steal_handle(parent_pid, pipe_handle)
fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
else:
- fd = handle
+ from . import semaphore_tracker
+ semaphore_tracker._semaphore_tracker_fd = tracker_fd
+ fd = pipe_handle
exitcode = _main(fd)
sys.exit(exitcode)