Limit download_dart_sdk task pool size on Windows (flutter/engine#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
This commit is contained in:
@@ -247,8 +247,21 @@ def Main():
|
||||
if architectures == None:
|
||||
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
|
||||
pool = multiprocessing.Pool()
|
||||
pool = multiprocessing.Pool(processes=max_processes)
|
||||
tasks = [(channel, semantic_version, os_name, arch, verbose) for arch in architectures]
|
||||
async_results = [pool.apply_async(DownloadAndExtract, t) for t in tasks]
|
||||
success = True
|
||||
|
||||
Reference in New Issue
Block a user