diff --git a/spoolman/database/database.py b/spoolman/database/database.py index 41f47c37d..5f6f9e386 100644 --- a/spoolman/database/database.py +++ b/spoolman/database/database.py @@ -61,18 +61,15 @@ def connect(self: "Database") -> None: logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO) connect_args = {} - if self.connection_url.drivername == "sqlite": - connect_args["check_same_thread"] = False - elif self.connection_url.drivername == "postgresql": - connect_args["options"] = "-c timezone=utc" - connect_args["max_inactive_connection_lifetime"] = 3 + if self.connection_url.drivername == "sqlite+aiosqlite": + connect_args["timeout"] = 60 self.engine = create_async_engine( self.connection_url, connect_args=connect_args, 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 diff --git a/tests_integration/tests/test_spool.py b/tests_integration/tests/test_spool.py index 609ad29bf..12f90625b 100644 --- a/tests_integration/tests/test_spool.py +++ b/tests_integration/tests/test_spool.py @@ -561,7 +561,7 @@ async def test_use_spool_concurrent(random_filament: dict[str, Any]): spool = result.json() # Execute - requests = 20 + requests = 100 used_weight = 0.5 async with httpx.AsyncClient() as client: tasks = []