1111
1212RETRY_METHODS = [
1313 "_get_block_handler" ,
14- "apply_type_registry_presets" ,
1514 "close" ,
1615 "compose_call" ,
17- "connect" ,
1816 "create_scale_object" ,
1917 "create_signed_extrinsic" ,
2018 "create_storage_key" ,
2119 "decode_scale" ,
2220 "encode_scale" ,
23- "extension_call" ,
24- "filter_events" ,
25- "filter_extrinsics" ,
2621 "generate_signature_payload" ,
2722 "get_account_next_index" ,
2823 "get_account_nonce" ,
3328 "get_block_number" ,
3429 "get_block_runtime_info" ,
3530 "get_block_runtime_version_for" ,
36- "get_block_timestamp" ,
3731 "get_chain_finalised_head" ,
3832 "get_chain_head" ,
3933 "get_constant" ,
5650 "get_type_registry" ,
5751 "init_runtime" ,
5852 "initialize" ,
59- "is_valid_ss58_address" ,
60- "load_runtime" ,
61- "make_payload" ,
6253 "query" ,
6354 "query_map" ,
6455 "query_multi" ,
6556 "query_multiple" ,
66- "reload_type_registry" ,
67- "retrieve_extrinsic_by_hash" ,
6857 "retrieve_extrinsic_by_identifier" ,
6958 "rpc_request" ,
7059 "runtime_call" ,
71- "search_block_number" ,
72- "serialize_constant" ,
73- "serialize_module_call" ,
74- "serialize_module_error" ,
75- "serialize_module_event" ,
76- "serialize_storage_item" ,
77- "ss58_decode" ,
78- "ss58_encode" ,
7960 "submit_extrinsic" ,
8061 "subscribe_block_headers" ,
8162 "supports_rpc_method" ,
@@ -132,14 +113,15 @@ def __init__(
132113 raise ConnectionError (
133114 f"Unable to connect at any chains specified: { [url ] + fallback_chains } "
134115 )
116+ self ._original_methods = {
117+ method : getattr (self , method ) for method in RETRY_METHODS
118+ }
135119 for method in RETRY_METHODS :
136120 setattr (self , method , partial (self ._retry , method ))
137- for property_ in RETRY_PROPS :
138- setattr (self , property_ , partial (self ._retry_property , property_ ))
139121
140122 def _retry (self , method , * args , ** kwargs ):
141123 try :
142- method_ = getattr ( self , method )
124+ method_ = self . _original_methods [ method ]
143125 return method_ (* args , ** kwargs )
144126 except (MaxRetriesExceeded , ConnectionError , ConnectionRefusedError ) as e :
145127 try :
@@ -222,10 +204,11 @@ def __init__(
222204 retry_timeout = retry_timeout ,
223205 max_retries = max_retries ,
224206 )
207+ self ._original_methods = {
208+ method : getattr (self , method ) for method in RETRY_METHODS
209+ }
225210 for method in RETRY_METHODS :
226211 setattr (self , method , partial (self ._retry , method ))
227- for property_ in RETRY_PROPS :
228- setattr (self , property_ , partial (self ._retry_property , property_ ))
229212
230213 def _reinstantiate_substrate (self , e : Optional [Exception ] = None ) -> None :
231214 next_network = next (self .fallback_chains )
@@ -248,11 +231,8 @@ def _reinstantiate_substrate(self, e: Optional[Exception] = None) -> None:
248231
249232 async def _retry (self , method , * args , ** kwargs ):
250233 try :
251- method_ = getattr (self , method )
252- if asyncio .iscoroutinefunction (method_ ):
253- return await method_ (* args , ** kwargs )
254- else :
255- return method_ (* args , ** kwargs )
234+ method_ = self ._original_methods [method ]
235+ return await method_ (* args , ** kwargs )
256236 except (MaxRetriesExceeded , ConnectionError , ConnectionRefusedError ) as e :
257237 try :
258238 self ._reinstantiate_substrate (e )
0 commit comments