Skip to content

Commit

Permalink
Revert worker limits (#273)
Browse files Browse the repository at this point in the history
black and gersemi 0.11.0 now limit their internal process pools to 60.
  • Loading branch information
calcmogul authored Feb 23, 2024
1 parent 6c93efd commit cdfd9eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions wpiformat/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ dynamic = [ "version" ]
readme = "README.rst"
dependencies = [
"regex==2023.10.3",
"black==23.9.1",
"black==24.2.0",
"clang-format==17.0.5",
"clang-tidy==17.0.1",
"gersemi==0.9.3"
"gersemi==0.11.0"
]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down
11 changes: 4 additions & 7 deletions wpiformat/wpiformat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ def main():
# on Windows. WaitForMultipleObjects() cannot wait on more then 64 events at
# once, and mp uses a few internal events. Therefore, the maximum number of
# parallel jobs is 60.
cpu_count = min(60, mp.cpu_count())
cpu_count = mp.cpu_count()
if sys.platform == "win32":
cpu_count = min(cpu_count, 60)
parser.add_argument(
"-j",
dest="jobs",
Expand Down Expand Up @@ -531,12 +533,7 @@ def main():
run_pipeline(task_pipeline, args, files)

# Lint is run last since previous tasks can affect its output.
# CMakeFormat doesn't work on high core count machines.
if mp.cpu_count() > 60:
task_pipeline = [PyFormat(), Lint()]
print("warning: Skipping CMake formatter due to too high CPU count.")
else:
task_pipeline = [CMakeFormat(), PyFormat(), Lint()]
task_pipeline = [CMakeFormat(), PyFormat(), Lint()]

run_batch(task_pipeline, args, file_batches)

Expand Down
7 changes: 1 addition & 6 deletions wpiformat/wpiformat/pyformat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This task runs black on files with Python extension."""

import multiprocessing as mp
import subprocess
import sys

Expand All @@ -15,11 +14,7 @@ def should_process_file(config_file, name):
@staticmethod
def run_batch(config_file, names):
try:
# Force at max 60 workers because black uses multiprocessing,
# and we need to keep the total number of multiprocessing processes
# below the Windows system limit.
cpu_count = min(60, mp.cpu_count())
args = [sys.executable, "-m", "black", "--workers", str(cpu_count), "-q"]
args = [sys.executable, "-m", "black", "-q"]
subprocess.run(args + names)
except FileNotFoundError:
print("Error: black not found in PATH. Is it installed?", file=sys.stderr)
Expand Down

0 comments on commit cdfd9eb

Please sign in to comment.