Fix typing

This commit is contained in:
Zakhar Izmaylov
2024-11-24 01:19:00 +03:00
parent fe59470256
commit 0867ebdd61
15 changed files with 210 additions and 251 deletions
+6 -7
View File
@@ -14,10 +14,9 @@ class DatabaseMiddleware(BaseMiddleware):
event: TelegramObject,
data: Dict[str, Any],
) -> Any:
async with await asyncpg.create_pool(DATABASE_URL) as pool:
async with pool.acquire() as session:
data["session"] = session
try:
return await handler(event, data)
finally:
await pool.release(session)
conn = await asyncpg.connect(DATABASE_URL)
try:
data["session"] = conn
return await handler(event, data)
finally:
await conn.close()