Skip to content

Commit

Permalink
NullPool is the answer for test runs
Browse files Browse the repository at this point in the history
  • Loading branch information
meksor committed Aug 12, 2024
1 parent 96fe9b8 commit 700911f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ixmp4/data/backend/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from sqlalchemy.engine import Engine, create_engine
from sqlalchemy.orm.session import sessionmaker
from sqlalchemy.pool import StaticPool
from sqlalchemy.pool import NullPool, StaticPool

from ixmp4.conf.base import PlatformInfo
from ixmp4.conf.manager import ManagerConfig, ManagerPlatformInfo
Expand Down Expand Up @@ -103,10 +103,6 @@ def make_repositories(self):
self.scenarios = ScenarioRepository(self)
self.units = UnitRepository(self)

def close(self):
self.session.close()
self.engine.dispose()

@contextmanager
def auth(
self,
Expand Down Expand Up @@ -134,6 +130,12 @@ def setup(self):
def teardown(self):
self.session.rollback()
self._drop_all()
self.engine = None
self.session = None

def close(self):
self.session.close()
self.engine.dispose()


class SqliteTestBackend(SqlAlchemyBackend):
Expand All @@ -160,5 +162,5 @@ def __init__(self, *args, **kwargs) -> None:
)

def make_engine(self, dsn: str):
self.engine = create_engine(dsn)
self.engine = create_engine(dsn, poolclass=NullPool)
self.session = self.Session(bind=self.engine)

0 comments on commit 700911f

Please sign in to comment.