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

@@ -726,8 +726,10 @@ async def url_handler(client: Client, message: Message):
return
# Add to queue (with duplicate URL check) AFTER saving to database
logger.info(f"Adding task {task_id} to queue (URL: {url[:50]}...)")
success = await task_queue.add_task(task, check_duplicate_url=True)
if not success:
logger.warning(f"Failed to add task {task_id} to queue (duplicate or error)")
# If failed to add to queue, remove from database
try:
async with get_async_session_local()() as session:
@@ -745,7 +747,11 @@ async def url_handler(client: Client, message: Message):
# Start executor if not already started
if not task_executor._running:
logger.info(f"Starting task executor for task {task_id}")
await task_executor.start()
logger.info(f"Task executor started, workers should begin processing tasks")
else:
logger.debug(f"Task executor already running, task {task_id} will be processed by existing workers")
# Send initial status message and save message_id for updates
from bot.modules.task_scheduler.executor import set_task_message