From 8329470b578540abcee27084893ce6b4e9a00ae6 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 20 Oct 2023 05:14:12 +0200 Subject: [PATCH] Core: explicitly limit threadpool (#2334) --- Main.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Main.py b/Main.py index dfc4ed179309..0995d2091f7b 100644 --- a/Main.py +++ b/Main.py @@ -301,15 +301,16 @@ def find_common_pool(players: Set[int], shared_pool: Set[str]) -> Tuple[ output = tempfile.TemporaryDirectory() with output as temp_dir: - with concurrent.futures.ThreadPoolExecutor(world.players + 2) as pool: + output_players = [player for player in world.player_ids if AutoWorld.World.generate_output.__code__ + is not world.worlds[player].generate_output.__code__] + with concurrent.futures.ThreadPoolExecutor(len(output_players) + 2) as pool: check_accessibility_task = pool.submit(world.fulfills_accessibility) output_file_futures = [pool.submit(AutoWorld.call_stage, world, "generate_output", temp_dir)] - for player in world.player_ids: + for player in output_players: # skip starting a thread for methods that say "pass". - if AutoWorld.World.generate_output.__code__ is not world.worlds[player].generate_output.__code__: - output_file_futures.append( - pool.submit(AutoWorld.call_single, world, "generate_output", player, temp_dir)) + output_file_futures.append( + pool.submit(AutoWorld.call_single, world, "generate_output", player, temp_dir)) # collect ER hint info er_hint_data: Dict[int, Dict[int, str]] = {}