@@ -119,6 +119,7 @@ def __init__(
119119 retry_forever : bool = False ,
120120 _mock : bool = False ,
121121 archive_endpoints : Optional [list [str ]] = None ,
122+ websocket_shutdown_timer : float = 5.0 ,
122123 ):
123124 """
124125 Initializes an instance of the AsyncSubtensor class.
@@ -157,6 +158,7 @@ def __init__(
157158 retry_forever = retry_forever ,
158159 _mock = _mock ,
159160 archive_endpoints = archive_endpoints ,
161+ ws_shutdown_timer = websocket_shutdown_timer ,
160162 )
161163 if self .log_verbose :
162164 logging .info (
@@ -296,6 +298,7 @@ def _get_substrate(
296298 retry_forever : bool = False ,
297299 _mock : bool = False ,
298300 archive_endpoints : Optional [list [str ]] = None ,
301+ ws_shutdown_timer : float = 5.0 ,
299302 ) -> Union [AsyncSubstrateInterface , RetryAsyncSubstrate ]:
300303 """Creates the Substrate instance based on provided arguments.
301304
@@ -307,6 +310,8 @@ def _get_substrate(
307310 archive_endpoints: Similar to fallback_endpoints, but specifically only archive nodes. Will be used in cases
308311 where you are requesting a block that is too old for your current (presumably lite) node. Defaults to
309312 `None`
313+ ws_shutdown_timer: Amount of time, in seconds, to wait after the last response from the chain to close the
314+ connection.
310315
311316 Returns:
312317 the instance of the SubstrateInterface or RetrySyncSubstrate class.
@@ -322,6 +327,7 @@ def _get_substrate(
322327 chain_name = "Bittensor" ,
323328 _mock = _mock ,
324329 archive_nodes = archive_endpoints ,
330+ ws_shutdown_timer = ws_shutdown_timer ,
325331 )
326332 return AsyncSubstrateInterface (
327333 url = self .chain_endpoint ,
@@ -330,6 +336,7 @@ def _get_substrate(
330336 use_remote_preset = True ,
331337 chain_name = "Bittensor" ,
332338 _mock = _mock ,
339+ ws_shutdown_timer = ws_shutdown_timer ,
333340 )
334341
335342 # Subtensor queries ===========================================================================================
0 commit comments