Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

fix: Make sure HTTP sessions are closed on shutdown

Clémence Lesné09deebbd65f3
diff --git a/app/main.py b/app/main.py
index 79546c7..3dcb862 100644
--- a/app/main.py
+++ b/app/main.py
@@ -57,7 +57,7 @@ from app.helpers.call_events import (
)
from app.helpers.call_utils import ContextEnum as CallContextEnum
from app.helpers.config import CONFIG
-from app.helpers.http import azure_transport
+from app.helpers.http import aiohttp_session, azure_transport
from app.helpers.logging import logger
from app.helpers.monitoring import SpanAttributes, span_attribute, tracer
from app.helpers.pydantic_types.phone_numbers import PhoneNumber
@@ -152,6 +152,9 @@ async def lifespan(app: FastAPI): # noqa: ARG001
if queue_tasks:
queue_tasks.cancel()
+ # Close HTTP session
+ await (await aiohttp_session()).close()
+
# FastAPI
api = FastAPI(