@@ -61,18 +61,15 @@ class Database:
|
|||||||
logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)
|
logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)
|
||||||
|
|
||||||
connect_args = {}
|
connect_args = {}
|
||||||
if self.connection_url.drivername == "sqlite":
|
if self.connection_url.drivername == "sqlite+aiosqlite":
|
||||||
connect_args["check_same_thread"] = False
|
connect_args["timeout"] = 60
|
||||||
elif self.connection_url.drivername == "postgresql":
|
|
||||||
connect_args["options"] = "-c timezone=utc"
|
|
||||||
connect_args["max_inactive_connection_lifetime"] = 3
|
|
||||||
|
|
||||||
self.engine = create_async_engine(
|
self.engine = create_async_engine(
|
||||||
self.connection_url,
|
self.connection_url,
|
||||||
connect_args=connect_args,
|
connect_args=connect_args,
|
||||||
pool_pre_ping=True,
|
pool_pre_ping=True,
|
||||||
)
|
)
|
||||||
self.session_maker = async_sessionmaker(self.engine, autocommit=False, autoflush=True)
|
self.session_maker = async_sessionmaker(self.engine, autocommit=False, autoflush=True, expire_on_commit=False)
|
||||||
|
|
||||||
|
|
||||||
__db: Optional[Database] = None
|
__db: Optional[Database] = None
|
||||||
|
|||||||
@@ -561,7 +561,7 @@ async def test_use_spool_concurrent(random_filament: dict[str, Any]):
|
|||||||
spool = result.json()
|
spool = result.json()
|
||||||
|
|
||||||
# Execute
|
# Execute
|
||||||
requests = 20
|
requests = 100
|
||||||
used_weight = 0.5
|
used_weight = 0.5
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
tasks = []
|
tasks = []
|
||||||
|
|||||||
Reference in New Issue
Block a user