This commit is contained in:
Dantenerosas 2023-09-26 00:24:38 +03:00 committed by nikili0n
parent 9edc954426
commit 24f09c2959
2 changed files with 8 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import concurrent.futures as pool
import subprocess import subprocess
from functools import partial from functools import partial
import traceback
from urllib.parse import urlparse from urllib.parse import urlparse
from src.core.async_queue import AsyncQueue from src.core.async_queue import AsyncQueue
@ -111,6 +112,12 @@ class MasterService:
"result": ex.default_message, "result": ex.default_message,
"status": "error" "status": "error"
}) })
except Exception as ex:
Result(result_type=ResultTypeEnum.EXCEPTION, value={
"link": video_params["link"],
"result": traceback.format_exc(),
"status": "error"
})
# TODO upload to server # TODO upload to server

View File

@ -59,7 +59,6 @@ queue_name -> {
} }
''' '''
async def is_task_already_done_or_exist(redis: RedisClient, link: str): async def is_task_already_done_or_exist(redis: RedisClient, link: str):
messages = await redis.get_task_done_queue() messages = await redis.get_task_done_queue()
temp = [json.loads(msg) for msg in messages] temp = [json.loads(msg) for msg in messages]
@ -96,6 +95,7 @@ async def index(request: Request):
async def get_url_for_download_video(request: Request, data: SubmitIn = Depends()): async def get_url_for_download_video(request: Request, data: SubmitIn = Depends()):
red = RedisClient() red = RedisClient()
task_done = await is_task_already_done_or_exist(red, data.link) task_done = await is_task_already_done_or_exist(red, data.link)
# TODO: где-то не обновился статус после выполнения\провала задачи
task_in_process = await is_task_in_process(red, data.link) task_in_process = await is_task_in_process(red, data.link)
if task_in_process: if task_in_process:
return JSONResponse({"result": "Задача в работе. Ожидайте"}) return JSONResponse({"result": "Задача в работе. Ожидайте"})