mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 02:41:06 -05:00
Added proper initialization sequence in the queue manager:
Sequential component initialization Coordination through an _initialized event Consistent lock hierarchy with _global_lock Updated the base cog to properly initialize components: Added timeout handling for queue manager initialization Ensures queue manager is fully initialized before starting queue processing Added proper error handling and cleanup Established consistent lock ordering: Global Lock -> Queue Lock -> Processing Lock Prevents circular wait conditions Each component respects the lock hierarchy Improved task coordination: Sequential initialization of components Proper waiting for initialization before starting operations Timeout handling for all async operations
This commit is contained in:
@@ -386,7 +386,20 @@ class VideoArchiver(GroupCog):
|
||||
max_history_age=86400,
|
||||
persistence_path=str(queue_path),
|
||||
)
|
||||
logger.info("Queue manager initialized")
|
||||
|
||||
# Initialize queue manager with timeout
|
||||
try:
|
||||
await asyncio.wait_for(
|
||||
self.queue_manager.initialize(),
|
||||
timeout=INIT_TIMEOUT
|
||||
)
|
||||
logger.info("Queue manager initialized successfully")
|
||||
except asyncio.TimeoutError:
|
||||
logger.error("Queue manager initialization timed out")
|
||||
raise ProcessingError("Queue manager initialization timed out")
|
||||
except Exception as e:
|
||||
logger.error(f"Queue manager initialization failed: {e}")
|
||||
raise
|
||||
|
||||
# Initialize processor with queue manager and shared FFmpeg manager
|
||||
self.processor = VideoProcessor(
|
||||
@@ -429,6 +442,7 @@ class VideoArchiver(GroupCog):
|
||||
logger.warning("Update checker start timed out")
|
||||
|
||||
# Start queue processing as a background task
|
||||
# Only start after queue manager is fully initialized
|
||||
self._queue_task = asyncio.create_task(
|
||||
self.queue_manager.process_queue(self.processor.process_video)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user