세션 및 비동기 처리 개선

This commit is contained in:
bluebamus committed 2025-12-29 23:46:21 +09:00
1 parent 153b9f0ca4
commit 5c99610e00
10 files changed
+4559 -289

No files matched your search

+4 -4
View File
@@ -6,7 +6,7 @@ Lyric Background Tasks
from sqlalchemy import select
from app.database.session import AsyncSessionLocal
from app.database.session import BackgroundSessionLocal
from app.lyric.models import Lyric
from app.utils.chatgpt_prompt import ChatgptService
@@ -55,8 +55,8 @@ async def generate_lyric_background(
pattern.lower() in result.lower() for pattern in failure_patterns
)
# Lyric 테이블 업데이트 (새 세션 사용)
async with AsyncSessionLocal() as session:
# Lyric 테이블 업데이트 (백그라운드 전용 세션 사용)
async with BackgroundSessionLocal() as session:
query_result = await session.execute(
select(Lyric)
.where(Lyric.task_id == task_id)
@@ -82,7 +82,7 @@ async def generate_lyric_background(
except Exception as e:
print(f"[generate_lyric_background] EXCEPTION - task_id: {task_id}, error: {e}")
# 실패 시 Lyric 테이블 업데이트
async with AsyncSessionLocal() as session:
async with BackgroundSessionLocal() as session:
query_result = await session.execute(
select(Lyric)
.where(Lyric.task_id == task_id)