Update requirements and insfra versions
This commit is contained in:
@@ -8,7 +8,7 @@ from typing import Optional, Dict, Any, List
|
||||
from sqlalchemy import create_engine, text
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker
|
||||
from sqlalchemy.orm import sessionmaker, declarative_base
|
||||
from sqlalchemy.pool import StaticPool, QueuePool
|
||||
from sqlalchemy.pool import StaticPool
|
||||
from contextlib import asynccontextmanager
|
||||
import structlog
|
||||
import time
|
||||
@@ -48,24 +48,24 @@ class DatabaseManager:
|
||||
self.pool_size = pool_size
|
||||
self.max_overflow = max_overflow
|
||||
|
||||
# Configure pool class based on database type
|
||||
poolclass = QueuePool
|
||||
if "sqlite" in database_url.lower():
|
||||
poolclass = StaticPool
|
||||
pool_size = 1
|
||||
max_overflow = 0
|
||||
|
||||
# Create async engine with enhanced configuration
|
||||
# Configure pool for async engines
|
||||
# Note: SQLAlchemy 2.0 async engines automatically use AsyncAdaptedQueuePool
|
||||
# We should NOT specify poolclass for async engines unless using StaticPool for SQLite
|
||||
engine_config = {
|
||||
"echo": echo,
|
||||
"pool_pre_ping": pool_pre_ping,
|
||||
"pool_recycle": pool_recycle,
|
||||
"pool_size": pool_size,
|
||||
"max_overflow": max_overflow,
|
||||
"poolclass": poolclass,
|
||||
"connect_args": {"command_timeout": connect_timeout},
|
||||
**engine_kwargs
|
||||
}
|
||||
|
||||
# Only set poolclass for SQLite (requires StaticPool for async)
|
||||
if "sqlite" in database_url.lower():
|
||||
engine_config["poolclass"] = StaticPool
|
||||
engine_config["pool_size"] = 1
|
||||
engine_config["max_overflow"] = 0
|
||||
|
||||
self.async_engine = create_async_engine(database_url, **engine_config)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user