Fixed the TypeError in _periodic_cleanup by adding runtime type checking and conversion:

Added checks to ensure added_at is always a datetime object before comparison
Converts string timestamps to datetime objects when needed
Implemented proper datetime serialization/deserialization in QueueItem:

to_dict method properly converts datetime objects to ISO format strings
from_dict method properly converts ISO format strings back to datetime objects
Added datetime handling for all datetime fields:

added_at
last_retry
last_error_time
This commit is contained in:
pacnpal
2024-11-15 17:32:12 +00:00
parent 285e64db21
commit 39169b3edb
2 changed files with 91 additions and 0 deletions

View File

@@ -655,12 +655,18 @@ class EnhancedVideoQueueManager:
# Clean up completed items
for url in list(self._completed.keys()):
item = self._completed[url]
# Ensure added_at is a datetime object
if isinstance(item.added_at, str):
item.added_at = datetime.fromisoformat(item.added_at)
if item.added_at < cleanup_cutoff:
self._completed.pop(url)
# Clean up failed items
for url in list(self._failed.keys()):
item = self._failed[url]
# Ensure added_at is a datetime object
if isinstance(item.added_at, str):
item.added_at = datetime.fromisoformat(item.added_at)
if item.added_at < cleanup_cutoff:
self._failed.pop(url)