세션 및 비동기 처리 개선
This commit is contained in:
1 parent
153b9f0ca4
commit
5c99610e00
10 files changed
+4559
-289
No files matched your search
@@ -10,7 +10,7 @@ import aiofiles
|
||||
import httpx
|
||||
from sqlalchemy import select
|
||||
|
||||
from app.database.session import AsyncSessionLocal
|
||||
from app.database.session import BackgroundSessionLocal
|
||||
from app.video.models import Video
|
||||
from app.utils.upload_blob_as_request import AzureBlobUploader
|
||||
|
||||
@@ -66,7 +66,7 @@ async def download_and_upload_video_to_blob(
|
||||
print(f"[download_and_upload_video_to_blob] Uploaded to Blob - task_id: {task_id}, url: {blob_url}")
|
||||
|
||||
# Video 테이블 업데이트 (새 세션 사용)
|
||||
async with AsyncSessionLocal() as session:
|
||||
async with BackgroundSessionLocal() as session:
|
||||
# 여러 개 있을 경우 가장 최근 것 선택
|
||||
result = await session.execute(
|
||||
select(Video)
|
||||
@@ -87,7 +87,7 @@ async def download_and_upload_video_to_blob(
|
||||
except Exception as e:
|
||||
print(f"[download_and_upload_video_to_blob] EXCEPTION - task_id: {task_id}, error: {e}")
|
||||
# 실패 시 Video 테이블 업데이트
|
||||
async with AsyncSessionLocal() as session:
|
||||
async with BackgroundSessionLocal() as session:
|
||||
result = await session.execute(
|
||||
select(Video)
|
||||
.where(Video.task_id == task_id)
|
||||
@@ -137,7 +137,7 @@ async def download_and_upload_video_by_creatomate_render_id(
|
||||
|
||||
try:
|
||||
# creatomate_render_id로 Video 조회하여 task_id 가져오기
|
||||
async with AsyncSessionLocal() as session:
|
||||
async with BackgroundSessionLocal() as session:
|
||||
result = await session.execute(
|
||||
select(Video)
|
||||
.where(Video.creatomate_render_id == creatomate_render_id)
|
||||
@@ -188,7 +188,7 @@ async def download_and_upload_video_by_creatomate_render_id(
|
||||
print(f"[download_and_upload_video_by_creatomate_render_id] Uploaded to Blob - creatomate_render_id: {creatomate_render_id}, url: {blob_url}")
|
||||
|
||||
# Video 테이블 업데이트 (새 세션 사용)
|
||||
async with AsyncSessionLocal() as session:
|
||||
async with BackgroundSessionLocal() as session:
|
||||
result = await session.execute(
|
||||
select(Video)
|
||||
.where(Video.creatomate_render_id == creatomate_render_id)
|
||||
@@ -209,7 +209,7 @@ async def download_and_upload_video_by_creatomate_render_id(
|
||||
print(f"[download_and_upload_video_by_creatomate_render_id] EXCEPTION - creatomate_render_id: {creatomate_render_id}, error: {e}")
|
||||
# 실패 시 Video 테이블 업데이트
|
||||
if task_id:
|
||||
async with AsyncSessionLocal() as session:
|
||||
async with BackgroundSessionLocal() as session:
|
||||
result = await session.execute(
|
||||
select(Video)
|
||||
.where(Video.creatomate_render_id == creatomate_render_id)
|
||||
|
||||
Reference in new issue
Block a user