Skip to content

Commit

Permalink
Core: explicitly limit threadpool (#2334)
Browse files Browse the repository at this point in the history
  • Loading branch information
Berserker66 authored Oct 20, 2023
1 parent 56796b7 commit 1a1d607
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = {}
Expand Down

0 comments on commit 1a1d607

Please sign in to comment.