Skip to content

Commit

Permalink
Catch exact exception
Browse files Browse the repository at this point in the history
  • Loading branch information
prehor committed Aug 13, 2023
1 parent d15513e commit 41a08b6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hddfancontrol/__init__.py
Expand Up @@ -975,7 +975,13 @@ def set_high_priority(logger: logging.Logger) -> None:
done = False
sched = os.SCHED_RR
try:
if os.sched_getscheduler(0) == sched:
current_sched = os.sched_getscheduler(0)
except OSError as e:
if e.errno != errno.ENOSYS:
raise
logger.warning(f"sched_getscheduler is not supported on this system, leaving scheduler as is")
else:
if current_sched == sched:
# already running with RR scheduler, likely set from init system, don't touch priority
done = True
else:
Expand All @@ -988,8 +994,6 @@ def set_high_priority(logger: logging.Logger) -> None:
else:
done = True
logger.info(f"Process real time scheduler set to {sched}, priority {prio}")
except OSError:
logger.warning(f"Failed to set real time process scheduler to {sched}")

if not done:
# renice to highest priority
Expand Down

0 comments on commit 41a08b6

Please sign in to comment.