Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to limit thread usage during optimize_images #89

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion data/example-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
"img_host_6": "ptscreens",
"img_host_7": "oeimg",


# Number of screenshots to capture
"screens": "6",

# Enable lossless PNG Compression (True/False)
"optimize_images": True,

# Use only half available CPU cores to avoid memory allocation errors
# Only when usig lossless compression
"shared_seedbox": False,

# The name of your default torrent client, set in the torrent client sections below
"default_torrent_client": "Client1",
Expand Down
7 changes: 7 additions & 0 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,13 @@ def valid_ss_time(self, ss_times, num_screens, length):

def optimize_images(self, image):
if self.config['DEFAULT'].get('optimize_images', True) is True:
if self.config['DEFAULT'].get('shared_seedbox', True) is True:
# Get number of CPU cores
num_cores = multiprocessing.cpu_count()
# Limit the number of threads based on half available cores
max_threads = num_cores // 2
# Set cores for oxipng usage
os.environ['RAYON_NUM_THREADS'] = str(max_threads)
if os.path.exists(image):
try:
pyver = platform.python_version_tuple()
Expand Down
Loading