From 67bcbc16051e64274f6aadb6f6830c1e58da0209 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:12:42 +0100 Subject: [PATCH] dispose stuff --- cashu/core/db.py | 2 +- cashu/mint/ledger.py | 2 +- pyproject.toml | 2 +- tests/test_db.py | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cashu/core/db.py b/cashu/core/db.py index 2a575dde..dc9dc212 100644 --- a/cashu/core/db.py +++ b/cashu/core/db.py @@ -228,7 +228,7 @@ def _is_lock_exception(e): ) else: logger.error(f"Error in session trial: {trial} ({random_int}): {e}") - raise e + raise finally: logger.trace(f"Closing session trial: {trial} ({random_int})") await session.close() diff --git a/cashu/mint/ledger.py b/cashu/mint/ledger.py index 8dae66c7..87505aa9 100644 --- a/cashu/mint/ledger.py +++ b/cashu/mint/ledger.py @@ -138,9 +138,9 @@ async def _startup_ledger(self): logger.info(f"Data dir: {settings.cashu_dir}") async def shutdown_ledger(self): - await self.db.engine.dispose() for task in self.invoice_listener_tasks: task.cancel() + await self.db.engine.dispose() async def _check_pending_proofs_and_melt_quotes(self): """Startup routine that checks all pending proofs for their melt state and either invalidates diff --git a/pyproject.toml b/pyproject.toml index 12169af8..5ccbba18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.pytest.ini_options] -asyncio_mode = "auto" +asyncio_mode = "strict" asyncio_default_fixture_loop_scope = "function" [tool.poetry.scripts] diff --git a/tests/test_db.py b/tests/test_db.py index d44e18cb..b3c32dcd 100644 --- a/tests/test_db.py +++ b/tests/test_db.py @@ -49,6 +49,7 @@ async def wallet(): ) await wallet.load_mint() yield wallet + await wallet.db.engine.dispose() @pytest.mark.asyncio