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: Close AI Translation connexion even if error

Clémence Lesné80ed4555e7ff
diff --git a/helpers/translation.py b/helpers/translation.py
index 04066e6..36beaa5 100644
--- a/helpers/translation.py
+++ b/helpers/translation.py
@@ -68,5 +68,7 @@ async def _use_client() -> AsyncGenerator[TextTranslationClient, None]:
),
endpoint=CONFIG.ai_translation.endpoint,
)
- yield client
- await client.close()
+ try:
+ yield client
+ finally:
+ await client.close()