Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a40675a

Browse files
committed
Issue #20990: Fix issues found by pyflakes for multiprocessing.
1 parent 75c5ab4 commit a40675a

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

Lib/multiprocessing/spawn.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ def freeze_support():
6464
Run code for process object if this in not the main process
6565
'''
6666
if is_forking(sys.argv):
67-
main()
67+
kwds = {}
68+
for arg in sys.argv[2:]:
69+
name, value = arg.split('=')
70+
if value == 'None':
71+
kwds[name] = None
72+
else:
73+
kwds[name] = int(value)
74+
spawn_main(**kwds)
6875
sys.exit()
6976

7077

@@ -73,7 +80,8 @@ def get_command_line(**kwds):
7380
Returns prefix of command line used for spawning a child process
7481
'''
7582
if getattr(sys, 'frozen', False):
76-
return [sys.executable, '--multiprocessing-fork']
83+
tmp = ' '.join('%s=%r' % item for item in kwds.items())
84+
return [sys.executable, '--multiprocessing-fork'] + tmp
7785
else:
7886
prog = 'from multiprocessing.spawn import spawn_main; spawn_main(%s)'
7987
prog %= ', '.join('%s=%r' % item for item in kwds.items())

Lib/multiprocessing/synchronize.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ class SemLock(object):
4949
_rand = tempfile._RandomNameSequence()
5050

5151
def __init__(self, kind, value, maxvalue, *, ctx):
52-
ctx = ctx or get_context()
53-
ctx = ctx.get_context()
54-
unlink_now = sys.platform == 'win32' or ctx._name == 'fork'
52+
if ctx is None:
53+
ctx = context._default_context.get_context()
54+
name = ctx.get_start_method()
55+
unlink_now = sys.platform == 'win32' or name == 'fork'
5556
for i in range(100):
5657
try:
5758
sl = self._semlock = _multiprocessing.SemLock(

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Core and Builtins
2121
Library
2222
-------
2323

24+
- Issue #20990: Fix issues found by pyflakes for multiprocessing.
25+
2426
- Issue #21015: SSL contexts will now automatically select an elliptic
2527
curve for ECDH key exchange on OpenSSL 1.0.2 and later, and otherwise
2628
default to "prime256v1".

0 commit comments

Comments
 (0)