From f85b194b64f4f95d74b9fec80d48e6f6b16d7bc1 Mon Sep 17 00:00:00 2001 From: BD Himes Date: Tue, 3 Feb 2026 19:09:51 +0200 Subject: [PATCH 1/2] Ensures we await committing after creating the table but before adding the trigger. --- async_substrate_interface/utils/cache.py | 1 + 1 file changed, 1 insertion(+) diff --git a/async_substrate_interface/utils/cache.py b/async_substrate_interface/utils/cache.py index 1b235e2..a01e4bb 100644 --- a/async_substrate_interface/utils/cache.py +++ b/async_substrate_interface/utils/cache.py @@ -61,6 +61,7 @@ async def _create_if_not_exists(self, chain: str, table_name: str): ); """ ) + await self._db.commit() await self._db.execute( f""" CREATE TRIGGER IF NOT EXISTS prune_rows_trigger_{table_name} AFTER INSERT ON {table_name} From 37a9240f18bec43d06cc800b1a2e6b37a61a0062 Mon Sep 17 00:00:00 2001 From: BD Himes Date: Tue, 3 Feb 2026 19:41:44 +0200 Subject: [PATCH 2/2] Move `_create_if_not_exists` to within the lock --- async_substrate_interface/async_substrate.py | 1 - async_substrate_interface/utils/cache.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/async_substrate_interface/async_substrate.py b/async_substrate_interface/async_substrate.py index 97aa604..177e0e2 100644 --- a/async_substrate_interface/async_substrate.py +++ b/async_substrate_interface/async_substrate.py @@ -2001,7 +2001,6 @@ async def result_handler( if subscription_result is not None: reached = True - logger.info("REACHED!") # Handler returned end result: unsubscribe from further updates async with self.ws as ws: await ws.unsubscribe( diff --git a/async_substrate_interface/utils/cache.py b/async_substrate_interface/utils/cache.py index a01e4bb..431a430 100644 --- a/async_substrate_interface/utils/cache.py +++ b/async_substrate_interface/utils/cache.py @@ -83,8 +83,8 @@ async def __call__(self, chain, other_self, func, args, kwargs) -> Optional[Any] if not self._db: _ensure_dir() self._db = await aiosqlite.connect(CACHE_LOCATION) - table_name = _get_table_name(func) - local_chain = await self._create_if_not_exists(chain, table_name) + table_name = _get_table_name(func) + local_chain = await self._create_if_not_exists(chain, table_name) key = pickle.dumps((args, kwargs or None)) try: cursor: aiosqlite.Cursor = await self._db.execute(