Compare commits

...

2 Commits

Author SHA1 Message Date
Nathan 5ab5571cf4 ignore specst/vscode 2026-05-21 21:29:25 -06:00
Nathan fd5c8a9ab4 use over 61 workers 2025-12-23 17:01:00 -07:00
4 changed files with 24 additions and 3975 deletions
+4
View File
@@ -2,3 +2,7 @@ input/
output/
corrupted/
.vscode/
.specstory/
-4
View File
@@ -1,4 +0,0 @@
# SpecStory project identity file
/.project.json
# SpecStory explanation file
/.what-is-this.md
+20 -1
View File
@@ -7,12 +7,21 @@ Compresses all PNG files in subdirectories with maximum parallelism.
import os
import sys
import argparse
import platform
from pathlib import Path
from concurrent.futures import ProcessPoolExecutor, as_completed
from PIL import Image
import multiprocessing
import time
# Try to unlock ProcessPoolExecutor on Windows to bypass 61-worker limit
try:
import unlock_processpool
unlock_processpool.please()
UNLOCKED = True
except ImportError:
UNLOCKED = False
def compress_png(input_path, output_path, force_bitdepth=None):
"""Compress a single PNG file.
@@ -311,7 +320,17 @@ def main():
print(f"Corrupted files will be moved to: {corrupted_dir}")
# Use all available CPU cores
max_workers = multiprocessing.cpu_count()
cpu_count = multiprocessing.cpu_count()
if platform.system() == 'Windows' and not UNLOCKED:
# Windows ProcessPoolExecutor has a maximum of 61 workers (unless unlocked)
max_workers = min(cpu_count, 61)
if cpu_count > 61:
print(f"Detected {cpu_count} CPU threads, but Windows limits ProcessPoolExecutor to 61 workers.")
print("Install 'unlock-processpool-win' package to use all cores: pip install unlock-processpool-win")
else:
max_workers = cpu_count
if UNLOCKED:
print(f"Using unlock-processpool-win to bypass Windows 61-worker limit")
print(f"Using {max_workers} worker processes for compression...")
print("-" * 80)