Commit ede96146 authored by Richard Oudkerk's avatar Richard Oudkerk

Issue #20990: Fix issues found by pyflakes for multiprocessing.

parent 13e8c9f1
...@@ -64,7 +64,14 @@ def freeze_support(): ...@@ -64,7 +64,14 @@ def freeze_support():
Run code for process object if this in not the main process Run code for process object if this in not the main process
''' '''
if is_forking(sys.argv): if is_forking(sys.argv):
main() kwds = {}
for arg in sys.argv[2:]:
name, value = arg.split('=')
if value == 'None':
kwds[name] = None
else:
kwds[name] = int(value)
spawn_main(**kwds)
sys.exit() sys.exit()
...@@ -73,7 +80,8 @@ def get_command_line(**kwds): ...@@ -73,7 +80,8 @@ def get_command_line(**kwds):
Returns prefix of command line used for spawning a child process Returns prefix of command line used for spawning a child process
''' '''
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
return [sys.executable, '--multiprocessing-fork'] tmp = ' '.join('%s=%r' % item for item in kwds.items())
return [sys.executable, '--multiprocessing-fork'] + tmp
else: else:
prog = 'from multiprocessing.spawn import spawn_main; spawn_main(%s)' prog = 'from multiprocessing.spawn import spawn_main; spawn_main(%s)'
prog %= ', '.join('%s=%r' % item for item in kwds.items()) prog %= ', '.join('%s=%r' % item for item in kwds.items())
......
...@@ -49,9 +49,10 @@ class SemLock(object): ...@@ -49,9 +49,10 @@ class SemLock(object):
_rand = tempfile._RandomNameSequence() _rand = tempfile._RandomNameSequence()
def __init__(self, kind, value, maxvalue, *, ctx): def __init__(self, kind, value, maxvalue, *, ctx):
ctx = ctx or get_context() if ctx is None:
ctx = ctx.get_context() ctx = context._default_context.get_context()
unlink_now = sys.platform == 'win32' or ctx._name == 'fork' name = ctx.get_start_method()
unlink_now = sys.platform == 'win32' or name == 'fork'
for i in range(100): for i in range(100):
try: try:
sl = self._semlock = _multiprocessing.SemLock( sl = self._semlock = _multiprocessing.SemLock(
......
...@@ -21,6 +21,8 @@ Core and Builtins ...@@ -21,6 +21,8 @@ Core and Builtins
Library Library
------- -------
- Issue #20990: Fix issues found by pyflakes for multiprocessing.
- Issue #21015: SSL contexts will now automatically select an elliptic - Issue #21015: SSL contexts will now automatically select an elliptic
curve for ECDH key exchange on OpenSSL 1.0.2 and later, and otherwise curve for ECDH key exchange on OpenSSL 1.0.2 and later, and otherwise
default to "prime256v1". default to "prime256v1".
......
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