Use atexit.register for shutdown handlers
MODIFY
plextraktsync/trakt/TraktBatch.py
plextraktsync/trakt/TraktBatch.py
from __future__ import annotations
+import atexit
from collections import defaultdict
from typing import TYPE_CHECKING
@@ -27,8 +28,7 @@ def __init__(self, name: str, add: bool, trakt: TraktApi, timer=None, cleanup: C
self.trakt = trakt
self.items = defaultdict(list)
self.timer = timer
- if cleanup:
- cleanup.add(self.flush)
+ atexit.register(self.flush)
@rate_limit()
@time_limit()

Use atexit.register for shutdown handlers