Add voice analytics filters and metrics
This commit is contained in:
17
backend/app/tasks/utils.py
Normal file
17
backend/app/tasks/utils.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""Shared helpers for Celery tasks."""
|
||||
|
||||
from collections.abc import Awaitable
|
||||
from typing import TypeVar
|
||||
|
||||
from app.db.database import dispose_engine
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
async def run_with_disposed_engine(awaitable: Awaitable[T]) -> T:
|
||||
"""Run async task work and drop DB pools before the event loop closes."""
|
||||
|
||||
try:
|
||||
return await awaitable
|
||||
finally:
|
||||
await dispose_engine()
|
||||
Reference in New Issue
Block a user