未验证 提交 c3db2dd9 编写于 作者: C Chris Bracken 提交者: GitHub

Limit download_dart_sdk task pool size on Windows (#28623)

The multiprocessing package relies on the win32 `WaitForMultipleObjects`
call, which supports waiting on a maximum of MAXIMUM_WAIT_OBJECTS
(defined by Windows to be 64) handles, processes in this case.  To avoid
hitting this, we limit ourselves to 60 handles (since there are a couple
extra processes launched for the queue reader and thread wakeup reader).

When left unspecified, the multiprocessing module defaults this value to
os.cpu_count(), so this error is triggered only on machines with > 60
cores.

See: https://bugs.python.org/issue2690

Bug: https://github.com/flutter/flutter/issues/90085
上级 df4eac9d
...@@ -247,8 +247,21 @@ def Main(): ...@@ -247,8 +247,21 @@ def Main():
if architectures == None: if architectures == None:
return fail_loudly return fail_loudly
# Work around a bug in Python.
#
# The multiprocessing package relies on the win32 WaitForMultipleObjects()
# call, which supports waiting on a maximum of MAXIMUM_WAIT_OBJECTS (defined
# by Windows to be 64) handles, processes in this case. To avoid hitting
# this, we limit ourselves to 60 handles (since there are a couple extra
# processes launched for the queue reader and thread wakeup reader).
#
# See: https://bugs.python.org/issue26903
max_processes = os.cpu_count()
if sys.platform.startswith(('cygwin', 'win')) and max_processes > 60:
max_processes = 60
# Download and extract variants in parallel # Download and extract variants in parallel
pool = multiprocessing.Pool() pool = multiprocessing.Pool(processes=max_processes)
tasks = [(channel, semantic_version, os_name, arch, verbose) for arch in architectures] tasks = [(channel, semantic_version, os_name, arch, verbose) for arch in architectures]
async_results = [pool.apply_async(DownloadAndExtract, t) for t in tasks] async_results = [pool.apply_async(DownloadAndExtract, t) for t in tasks]
success = True success = True
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册