mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 15:48:58 +00:00
Windows waits on a pool's workers with WaitForMultipleObjects, which takes at most 64 handles. With --jobs 62 or more, awc_opus.py, awc_shorts.py, world_lights_paths.py and world_build.py stopped with "ValueError: max_workers must be <= 61" (ProcessPoolExecutor), and anim_clips.py (multiprocessing.Pool) printed "ValueError: need at most 63 handles" from a helper thread and never returned: 62 workers were killed after 60 s where 61 finish in 0.8 s (Windows 11, Python 3.12.5). awc_opus.py and awc_shorts.py default --jobs to half the CPU count, and make_game.py hands its own --jobs to awc_opus.py, so a machine with 124 logical CPUs reached this with no option given. tools/pool_workers.py holds the limit, and the five pools are created with process_workers(jobs): unchanged elsewhere, 61 at most on Windows. The job count is lowered rather than refused so that a build with a large --jobs keeps running. world_census.py, which refuses --jobs above 61, is not changed. tests/test_pool_workers.py runs each tool's own code: with the limit patched in and a recording pool (every platform), the audio tools from the command line with --jobs 62, and the real pool with 62 jobs on Windows. 8 of its 10 tests fail on the tools as they were. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
20 lines
1.1 KiB
Python
20 lines
1.1 KiB
Python
"""How many worker processes one pool can have on this platform.
|
|
|
|
Windows waits on a pool's workers with WaitForMultipleObjects, which takes at most 64 handles. Above 61 workers
|
|
concurrent.futures.ProcessPoolExecutor raises `ValueError: max_workers must be <= 61`, and multiprocessing.Pool
|
|
prints `ValueError: need at most 63 handles` from its result thread and never returns (measured on Windows 11,
|
|
Python 3.12.5: 62 workers were killed after 60 s, 61 finished in 0.8 s). A tool whose --jobs defaults to half the
|
|
CPU count, or is handed make_game.py's, reaches that on a large machine with no option given.
|
|
|
|
A pool is therefore created with process_workers(jobs): the same number everywhere else, 61 at most on Windows.
|
|
Threads have no such limit. tools/world_census.py rejects --jobs above the limit instead (its MAX_JOBS).
|
|
"""
|
|
import os
|
|
|
|
MAX_PROCESS_WORKERS = 61 if os.name == "nt" else None
|
|
|
|
|
|
def process_workers(jobs):
|
|
"""`jobs`, lowered to the most worker processes one pool can have here."""
|
|
return jobs if MAX_PROCESS_WORKERS is None else min(jobs, MAX_PROCESS_WORKERS)
|