55"""
66
77import asyncio
8- from concurrent .futures import ProcessPoolExecutor
98import inspect
109import logging
1110import random
5756)
5857from async_substrate_interface .utils .storage import StorageKey
5958from async_substrate_interface .type_registry import _TYPE_REGISTRY
60- from async_substrate_interface .utils .decoding_attempt import _decode_query_map , _decode_scale_with_runtime
59+ from async_substrate_interface .utils .decoding_attempt import (
60+ decode_query_map ,
61+ _decode_scale_with_runtime ,
62+ )
6163
6264if TYPE_CHECKING :
6365 from websockets .asyncio .client import ClientConnection
66+ from concurrent .futures import ProcessPoolExecutor
6467
6568ResultHandler = Callable [[dict , Any ], Awaitable [tuple [dict , bool ]]]
6669
@@ -415,7 +418,7 @@ def __init__(
415418 last_key : Optional [str ] = None ,
416419 max_results : Optional [int ] = None ,
417420 ignore_decoding_errors : bool = False ,
418- executor : Optional ["ProcessPoolExecutor" ] = None
421+ executor : Optional ["ProcessPoolExecutor" ] = None ,
419422 ):
420423 self .records = records
421424 self .page_size = page_size
@@ -441,7 +444,7 @@ async def retrieve_next_page(self, start_key) -> list:
441444 start_key = start_key ,
442445 max_results = self .max_results ,
443446 ignore_decoding_errors = self .ignore_decoding_errors ,
444- executor = self .executor
447+ executor = self .executor ,
445448 )
446449 if len (result .records ) < self .page_size :
447450 self .loading_complete = True
@@ -867,7 +870,6 @@ async def encode_scale(
867870 await self ._wait_for_registry (_attempt , _retries )
868871 return self ._encode_scale (type_string , value )
869872
870-
871873 async def decode_scale (
872874 self ,
873875 type_string : str ,
@@ -2865,7 +2867,7 @@ async def query_map(
28652867 page_size : int = 100 ,
28662868 ignore_decoding_errors : bool = False ,
28672869 reuse_block_hash : bool = False ,
2868- executor : Optional ["ProcessPoolExecutor" ] = None
2870+ executor : Optional ["ProcessPoolExecutor" ] = None ,
28692871 ) -> AsyncQueryMapResult :
28702872 """
28712873 Iterates over all key-pairs located at the given module and storage_function. The storage
@@ -2982,13 +2984,15 @@ async def query_map(
29822984 # )
29832985 result = await asyncio .get_running_loop ().run_in_executor (
29842986 executor ,
2985- _decode_query_map ,
2987+ decode_query_map ,
29862988 result_group ["changes" ],
29872989 prefix ,
29882990 runtime .registry .registry ,
29892991 param_types ,
29902992 params ,
2991- value_type , key_hashers , ignore_decoding_errors
2993+ value_type ,
2994+ key_hashers ,
2995+ ignore_decoding_errors ,
29922996 )
29932997 # max_workers = executor._max_workers
29942998 # result_group_changes_groups = [result_group["changes"][i:i + max_workers] for i in range(0, len(result_group["changes"]), max_workers)]
@@ -3006,13 +3010,15 @@ async def query_map(
30063010 # for r in all_results:
30073011 # result.extend(r)
30083012 else :
3009- result = _decode_query_map (
3013+ result = decode_query_map (
30103014 result_group ["changes" ],
30113015 prefix ,
30123016 runtime .registry .registry ,
30133017 param_types ,
30143018 params ,
3015- value_type , key_hashers , ignore_decoding_errors
3019+ value_type ,
3020+ key_hashers ,
3021+ ignore_decoding_errors ,
30163022 )
30173023 return AsyncQueryMapResult (
30183024 records = result ,
@@ -3025,7 +3031,7 @@ async def query_map(
30253031 last_key = last_key ,
30263032 max_results = max_results ,
30273033 ignore_decoding_errors = ignore_decoding_errors ,
3028- executor = executor
3034+ executor = executor ,
30293035 )
30303036
30313037 async def submit_extrinsic (
0 commit comments