0
1
mirror of https://github.com/radio95-rnt/RadioPlayer.git synced 2026-02-26 13:52:00 +01:00

add a shutdown function

This commit is contained in:
2025-11-23 12:14:18 +01:00
parent c87b5f7a27
commit 5e0bc2c99c
3 changed files with 8 additions and 0 deletions

View File

@@ -86,6 +86,11 @@ class PlayerModule(BaseIMCModule):
Please don't put any blocking or code that takes time
"""
pass
def shutdown(self):
"""
Ran while shutting down
"""
pass
class PlaylistModifierModule:
"""
Playlist modifier, this type of module allows you to shuffle, or put jingles into your playlist

View File

@@ -34,5 +34,7 @@ class Module(PlayerModule):
def on_new_track(self, index: int, track: Track, next_track: Track | None) -> None:
self.counts[track.path.as_posix()] = self.counts.get(track.path.as_posix(), 0) + 1
if sum(self.counts.values()) % 3 == 0: self._save_counts()
def shutdown(self):
self._save_counts()
module = Module()

View File

@@ -131,6 +131,7 @@ class RadioPlayer:
def shutdown(self):
self.procman.stop_all()
[module.shutdown() for module in self.simple_modules if module]
def handle_sigint(self, signum, frame):
with self.exit_lock: