File tree 1 file changed +6
-3
lines changed
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,7 @@ def __init__(
186
186
187
187
self .log_verbose = log_verbose
188
188
self ._connection_timeout = connection_timeout
189
+ self .substrate : "SubstrateInterface" = None
189
190
self ._get_substrate ()
190
191
191
192
def __str__ (self ) -> str :
@@ -201,7 +202,8 @@ def __repr__(self) -> str:
201
202
202
203
def close (self ):
203
204
"""Cleans up resources for this subtensor instance like active websocket connection and active extensions."""
204
- self .substrate .close ()
205
+ if self .substrate :
206
+ self .substrate .close ()
205
207
206
208
def _get_substrate (self ):
207
209
"""Establishes a connection to the Substrate node using configured parameters."""
@@ -223,14 +225,15 @@ def _get_substrate(self):
223
225
except (AttributeError , TypeError , socket .error , OSError ) as e :
224
226
logging .warning (f"Error setting timeout: { e } " )
225
227
226
- except ConnectionRefusedError :
228
+ except ConnectionRefusedError as error :
227
229
logging .error (
228
230
f"Could not connect to { self .network } network with { self .chain_endpoint } chain endpoint." ,
229
231
)
230
232
logging .info (
231
233
"You can check if you have connectivity by running this command: nc -vz localhost "
232
- f"{ self .chain_endpoint . split ( ':' )[ 2 ] } "
234
+ f"{ self .chain_endpoint } "
233
235
)
236
+ raise ConnectionRefusedError (error .args )
234
237
235
238
@staticmethod
236
239
def config () -> "Config" :
You can’t perform that action at this time.
0 commit comments