Skip to content

Commit ca85ff9

Browse files
committed
Clean up debug
1 parent b1408a2 commit ca85ff9

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

async_substrate_interface/async_substrate.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4183,12 +4183,11 @@ async def close(self):
41834183
"""
41844184
try:
41854185
await self.runtime_cache.dump_to_disk(self.url)
4186-
print(4276)
41874186
await self.ws.shutdown()
41884187
except AttributeError:
41894188
pass
4190-
for db in AsyncSqliteDB._instances.values():
4191-
await db.close()
4189+
db = AsyncSqliteDB(self.url)
4190+
await db.close()
41924191

41934192
@async_sql_lru_cache(maxsize=SUBSTRATE_CACHE_METHOD_SIZE)
41944193
async def get_parent_block_hash(self, block_hash):

async_substrate_interface/utils/cache.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def __new__(cls, chain_endpoint: str):
4141
async def close(self):
4242
async with self._lock:
4343
if self._db:
44-
print(44)
4544
await self._db.close()
4645

4746
async def _create_if_not_exists(self, chain: str, table_name: str):
@@ -164,22 +163,21 @@ async def dump_runtime_cache(
164163
local_chain = await self._create_if_not_exists(chain, table)
165164
if local_chain:
166165
return None
167-
166+
serialized_mapping = {}
168167
for key, value in mapping.items():
169168
if not isinstance(value, (str, int)):
170-
serialized_runtime = pickle.dumps(value.serialize())
169+
serialized_value = pickle.dumps(value.serialize())
171170
else:
172-
serialized_runtime = pickle.dumps(value)
173-
174-
await self._db.execute(
175-
f"INSERT OR REPLACE INTO {table} (key, value, chain) VALUES (?,?,?)",
176-
(key, serialized_runtime, chain),
177-
)
178-
179-
# await self._db.executemany(
180-
# f"INSERT OR REPLACE INTO {table} (key, value, chain) VALUES (?,?,?)",
181-
# [(key, pickle.dumps(runtime.serialize()), chain) for key, runtime in mapping.items()],
182-
# )
171+
serialized_value = pickle.dumps(value)
172+
serialized_mapping[key] = serialized_value
173+
174+
await self._db.executemany(
175+
f"INSERT OR REPLACE INTO {table} (key, value, chain) VALUES (?,?,?)",
176+
[
177+
(key, serialized_value_, chain)
178+
for key, serialized_value_ in serialized_mapping.items()
179+
],
180+
)
183181

184182
await self._db.commit()
185183

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ keywords = ["substrate", "development", "bittensor"]
88

99
dependencies = [
1010
"wheel",
11-
"aiosqlite>=0.21.0,<1.0.0"
11+
"aiosqlite>=0.21.0,<1.0.0",
1212
"bt-decode==v0.8.0",
1313
"scalecodec~=1.2.11",
1414
"websockets>=14.1",

0 commit comments

Comments
 (0)