5
5
"""
6
6
7
7
import asyncio
8
- from concurrent .futures import ProcessPoolExecutor
9
8
import inspect
10
9
import logging
11
10
import random
57
56
)
58
57
from async_substrate_interface .utils .storage import StorageKey
59
58
from 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
+ )
61
63
62
64
if TYPE_CHECKING :
63
65
from websockets .asyncio .client import ClientConnection
66
+ from concurrent .futures import ProcessPoolExecutor
64
67
65
68
ResultHandler = Callable [[dict , Any ], Awaitable [tuple [dict , bool ]]]
66
69
@@ -415,7 +418,7 @@ def __init__(
415
418
last_key : Optional [str ] = None ,
416
419
max_results : Optional [int ] = None ,
417
420
ignore_decoding_errors : bool = False ,
418
- executor : Optional ["ProcessPoolExecutor" ] = None
421
+ executor : Optional ["ProcessPoolExecutor" ] = None ,
419
422
):
420
423
self .records = records
421
424
self .page_size = page_size
@@ -441,7 +444,7 @@ async def retrieve_next_page(self, start_key) -> list:
441
444
start_key = start_key ,
442
445
max_results = self .max_results ,
443
446
ignore_decoding_errors = self .ignore_decoding_errors ,
444
- executor = self .executor
447
+ executor = self .executor ,
445
448
)
446
449
if len (result .records ) < self .page_size :
447
450
self .loading_complete = True
@@ -867,7 +870,6 @@ async def encode_scale(
867
870
await self ._wait_for_registry (_attempt , _retries )
868
871
return self ._encode_scale (type_string , value )
869
872
870
-
871
873
async def decode_scale (
872
874
self ,
873
875
type_string : str ,
@@ -2865,7 +2867,7 @@ async def query_map(
2865
2867
page_size : int = 100 ,
2866
2868
ignore_decoding_errors : bool = False ,
2867
2869
reuse_block_hash : bool = False ,
2868
- executor : Optional ["ProcessPoolExecutor" ] = None
2870
+ executor : Optional ["ProcessPoolExecutor" ] = None ,
2869
2871
) -> AsyncQueryMapResult :
2870
2872
"""
2871
2873
Iterates over all key-pairs located at the given module and storage_function. The storage
@@ -2982,13 +2984,15 @@ async def query_map(
2982
2984
# )
2983
2985
result = await asyncio .get_running_loop ().run_in_executor (
2984
2986
executor ,
2985
- _decode_query_map ,
2987
+ decode_query_map ,
2986
2988
result_group ["changes" ],
2987
2989
prefix ,
2988
2990
runtime .registry .registry ,
2989
2991
param_types ,
2990
2992
params ,
2991
- value_type , key_hashers , ignore_decoding_errors
2993
+ value_type ,
2994
+ key_hashers ,
2995
+ ignore_decoding_errors ,
2992
2996
)
2993
2997
# max_workers = executor._max_workers
2994
2998
# 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(
3006
3010
# for r in all_results:
3007
3011
# result.extend(r)
3008
3012
else :
3009
- result = _decode_query_map (
3013
+ result = decode_query_map (
3010
3014
result_group ["changes" ],
3011
3015
prefix ,
3012
3016
runtime .registry .registry ,
3013
3017
param_types ,
3014
3018
params ,
3015
- value_type , key_hashers , ignore_decoding_errors
3019
+ value_type ,
3020
+ key_hashers ,
3021
+ ignore_decoding_errors ,
3016
3022
)
3017
3023
return AsyncQueryMapResult (
3018
3024
records = result ,
@@ -3025,7 +3031,7 @@ async def query_map(
3025
3031
last_key = last_key ,
3026
3032
max_results = max_results ,
3027
3033
ignore_decoding_errors = ignore_decoding_errors ,
3028
- executor = executor
3034
+ executor = executor ,
3029
3035
)
3030
3036
3031
3037
async def submit_extrinsic (
0 commit comments