Skip to content

Commit

Permalink
added niceness
Browse files Browse the repository at this point in the history
  • Loading branch information
Barakudum committed Feb 4, 2024
1 parent 79bf9dd commit 324c44a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/jarklin/_commands/_get_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from functools import cache
import configlib.finder
from ._logging import configure_logging
from ._process_config import configure_process


@cache
Expand All @@ -22,4 +23,5 @@ def get_config() -> 'configlib.ConfigInterface':
else:
config = configlib.load(fp=fp)
configure_logging(config=config)
configure_process(config=config)
return config
2 changes: 1 addition & 1 deletion src/jarklin/_commands/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
DEFAULT_DATEFORMAT = "%Y-%m-%d %H:%M:%S"


def configure_logging(config: ConfigInterface):
def configure_logging(config: ConfigInterface) -> None:
handlers = []

if config.getboolean('logging', 'console', fallback=True):
Expand Down
20 changes: 20 additions & 0 deletions src/jarklin/_commands/_process_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding=utf-8 -*-
r"""
"""
import os
import logging
from configlib import ConfigInterface


def configure_process(config: ConfigInterface) -> None:
if hasattr(os, 'nice'):
niceness = os.environ.get('NICENESS')
if niceness is not None:
niceness = int(niceness)
if niceness is None:
niceness = config.getint('process', 'niceness', fallback=None)
if niceness is not None:
current = os.nice(0)
current = os.nice(-current + niceness)
logging.debug(f'Updated Niceness to: {current}')
1 change: 1 addition & 0 deletions src/jarklin/cache/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def generate_previews(self) -> None:
.filter('select', "+".join(f"eq(n,{frame})" for frame in extract_frames))
.filter('scale', *scale)
.output(str(self.previews_cache.joinpath("%d.jpg")), vframes=len(extract_frames), vsync=0)
# .global_args('-threads', str(self.config.getint('cache', 'video', 'ffmpeg', 'threads', fallback=0)))
.run(quiet=True, overwrite_output=True)
)

Expand Down

0 comments on commit 324c44a

Please sign in to comment.