fix downloader

This commit is contained in:
2025-12-05 22:53:59 +03:00
parent e635a6fb0d
commit 541b5a9218
3 changed files with 21 additions and 2 deletions

View File

@@ -196,6 +196,8 @@ class TaskExecutor:
await asyncio.sleep(0.5)
continue
logger.info(f"Worker {name} got task {task.id} from queue (URL: {task.url[:50] if task.url else 'N/A'}...)")
# Check for cancellation before starting processing
current_task = await task_queue.get_task_by_id(task.id)
if current_task and current_task.status == TaskStatus.CANCELLED:
@@ -204,13 +206,14 @@ class TaskExecutor:
# Update status
await task_queue.update_task_status(task.id, TaskStatus.PROCESSING)
logger.info(f"Worker {name} processing task {task.id}")
logger.info(f"Worker {name} processing task {task.id} (status: PROCESSING)")
# Execute task (doesn't block other workers and message processing)
# Each task executes independently
await self._execute_task(task)
logger.info(f"Worker {name} completed task {task.id}")
except asyncio.CancelledError:
logger.info(f"Worker {name} stopped")
break
@@ -281,6 +284,8 @@ class TaskExecutor:
async def _download_with_ytdlp(self, task: Task):
"""Download via yt-dlp"""
logger.info(f"Starting download for task {task.id}: {task.url}")
# Get cancellation event for this task
cancel_event = task_queue.get_cancel_event(task.id)
@@ -296,7 +301,9 @@ class TaskExecutor:
from bot.modules.media_loader.ytdlp import get_media_info
from shared.config import settings
logger.info(f"Getting media info for task {task.id}...")
media_info = await get_media_info(task.url, cookies_file=settings.COOKIES_FILE)
logger.info(f"Media info retrieved for task {task.id}: title={media_info.get('title') if media_info else 'N/A'}")
if media_info:
# Check duration
max_duration = settings.max_duration_minutes_int