Close sessions for all services on shutdown

This commit is contained in:
Machka Pasla
2025-07-29 14:44:55 +03:00
parent 14f244ab79
commit 8246e9a590
4 changed files with 48 additions and 7 deletions
+9
View File
@@ -46,6 +46,15 @@ class CryptoPayService:
self.client = None
self.configured = False
async def close(self):
"""Close underlying AioCryptoPay session if initialized."""
if self.client:
try:
await self.client.close()
logging.info("CryptoPay client session closed.")
except Exception as e:
logging.warning(f"Failed to close CryptoPay client: {e}")
async def create_invoice(
self,
session: AsyncSession,