This commit is contained in:
pacnpal
2024-11-18 00:51:55 +00:00
parent afe0e96b14
commit 7276e37cab
5 changed files with 14 additions and 8 deletions

View File

@@ -49,7 +49,7 @@ from .reactions import (
)
# Import progress tracking
from ..utils.progress_tracker import progress_tracker
from ..utils.progress_tracker import ProgressTracker
# Import handlers after other dependencies are loaded
from .message_handler import MessageHandler
@@ -113,6 +113,7 @@ __description__ = "Video processing module for archiving Discord videos"
# Create shared instances for module-level access
url_extractor = URLExtractor()
message_validator = MessageValidator()
progress_tracker = ProgressTracker() # Create singleton instance
# URL extraction helper functions

View File

@@ -10,7 +10,7 @@ from discord.ext import commands # type: ignore
from videoarchiver.core.types import ComponentState, ProcessorState, ComponentStatus, IComponent, IConfigManager, IQueueManager
from videoarchiver.processor.constants import REACTIONS
from videoarchiver.utils import progress_tracker
from videoarchiver.utils.progress_tracker import ProgressTracker
from videoarchiver.utils.exceptions import ProcessorError
logger = logging.getLogger("VideoArchiver")
@@ -90,6 +90,7 @@ class HealthMonitor:
self.last_check: Optional[datetime] = None
self.health_status: Dict[str, bool] = {}
self._monitor_task: Optional[asyncio.Task] = None
self.progress_tracker = ProgressTracker() # Initialize ProgressTracker instance
async def start_monitoring(self) -> None:
"""Start health monitoring"""
@@ -116,7 +117,7 @@ class HealthMonitor:
self.health_status.update({
"queue_handler": self.processor.queue_handler.is_healthy(),
"message_handler": self.processor.message_handler.is_healthy(),
"progress_tracker": progress_tracker.is_healthy(),
"progress_tracker": self.progress_tracker.is_healthy(),
})
# Check operation health

View File

@@ -17,6 +17,7 @@ try:
from ..utils.exceptions import QueueHandlerError
from ..queue.models import QueueItem
from ..config_manager import ConfigManager
from . import progress_tracker # Import from processor package
from .constants import REACTIONS
except ImportError:
# Fall back to absolute imports if relative imports fail
@@ -27,6 +28,7 @@ except ImportError:
from videoarchiver.utils.exceptions import QueueHandlerError
from videoarchiver.queue.models import QueueItem
from videoarchiver.config_manager import ConfigManager
from videoarchiver.processor import progress_tracker # Import from processor package
from videoarchiver.processor.constants import REACTIONS
logger = logging.getLogger("VideoArchiver")
@@ -390,7 +392,7 @@ class QueueHandler:
return
# Update progress tracking
utils.progress_tracker.update_download_progress(
progress_tracker.update_download_progress(
url,
{
"percent": progress,
@@ -437,9 +439,9 @@ class QueueHandler:
download_task, timeout=self.DOWNLOAD_TIMEOUT
)
if success:
utils.progress_tracker.complete_download(url)
progress_tracker.complete_download(url)
else:
utils.progress_tracker.increment_download_retries(url)
progress_tracker.increment_download_retries(url)
return success, file_path, error
except asyncio.TimeoutError: