Skip to content

Commit

Permalink
tools: they no longer crash on windows with more than 60 logical cpu …
Browse files Browse the repository at this point in the history
…cores
  • Loading branch information
GValiente committed Sep 6, 2024
1 parent 8550233 commit 1caee04
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
5 changes: 5 additions & 0 deletions butano/include/documentation/bn_documentation_g_changelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
* @tableofcontents
*
*
* @section changelog_18_0_1 18.0.1 (next release)
*
* Tools no longer crash on Windows with more than 60 logical CPU cores.
*
*
* @section changelog_18_0_0 18.0.0
*
* * Language standard updated to C++23.
Expand Down
4 changes: 2 additions & 2 deletions butano/tools/butano_dmg_audio_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import os
import json
import sys
from multiprocessing import Pool

from file_info import FileInfo
from pool import create_pool


class DmgAudioFileInfo:
Expand Down Expand Up @@ -242,7 +242,7 @@ def process_dmg_audio(audio_paths, build_folder_path):

sys.stdout.flush()

pool = Pool()
pool = create_pool()
process_results = pool.map(DmgAudioFileInfoProcessor(build_folder_path), audio_file_infos)
pool.close()

Expand Down
4 changes: 2 additions & 2 deletions butano/tools/butano_graphics_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import string
import subprocess
import sys
from multiprocessing import Pool

from bmp import BMP
from file_info import FileInfo
from pool import create_pool


def parse_colors_count(info, bmp, tag='colors_count'):
Expand Down Expand Up @@ -1764,7 +1764,7 @@ def process_graphics(grit, graphics_paths, build_folder_path):

sys.stdout.flush()

pool = Pool()
pool = create_pool()
process_results = pool.map(GraphicsFileInfoProcessor(grit, build_folder_path), graphics_file_infos)
pool.close()

Expand Down
16 changes: 16 additions & 0 deletions butano/tools/pool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Copyright (c) 2020-2024 Gustavo Valiente [email protected]
zlib License, see LICENSE file.
"""

import multiprocessing
import os


def create_pool():
processes = multiprocessing.cpu_count()

if os.name == 'nt':
processes = min(processes, 60)

return multiprocessing.Pool(processes)
3 changes: 2 additions & 1 deletion docs/changelog.html

Large diffs are not rendered by default.

0 comments on commit 1caee04

Please sign in to comment.