@@ -815,12 +815,20 @@ async def all_subnets(
815
815
block_hash = block_hash ,
816
816
),
817
817
self .get_subnet_prices (block_hash = block_hash ),
818
+ return_exceptions = True ,
818
819
)
819
820
820
821
decoded = query .decode ()
821
822
822
- for sn in decoded :
823
- sn .update ({"price" : subnet_prices .get (sn ["netuid" ], Balance .from_tao (0 ))})
823
+ if not isinstance (subnet_prices , SubstrateRequestException ):
824
+ for sn in decoded :
825
+ sn .update (
826
+ {"price" : subnet_prices .get (sn ["netuid" ], Balance .from_tao (0 ))}
827
+ )
828
+ else :
829
+ logging .warning (
830
+ f"Unable to fetch subnet prices for block { block_number } , block hash { block_hash } "
831
+ )
824
832
return DynamicInfo .list_from_dicts (decoded )
825
833
826
834
async def blocks_since_last_step (
@@ -1129,21 +1137,30 @@ async def get_all_subnets_info(
1129
1137
Notes:
1130
1138
See also: <https://docs.learnbittensor.org/glossary#subnet>
1131
1139
"""
1132
- result = await self .query_runtime_api (
1133
- runtime_api = "SubnetInfoRuntimeApi" ,
1134
- method = "get_subnets_info_v2" ,
1135
- params = [],
1136
- block = block ,
1137
- block_hash = block_hash ,
1138
- reuse_block = reuse_block ,
1140
+ result , prices = await asyncio .gather (
1141
+ self .query_runtime_api (
1142
+ runtime_api = "SubnetInfoRuntimeApi" ,
1143
+ method = "get_subnets_info_v2" ,
1144
+ params = [],
1145
+ block = block ,
1146
+ block_hash = block_hash ,
1147
+ reuse_block = reuse_block ,
1148
+ ),
1149
+ self .get_subnet_prices (
1150
+ block = block , block_hash = block_hash , reuse_block = reuse_block
1151
+ ),
1152
+ return_exceptions = True ,
1139
1153
)
1140
1154
if not result :
1141
1155
return []
1142
1156
1143
- subnets_prices = await self .get_subnet_prices ()
1144
-
1145
- for subnet in result :
1146
- subnet .update ({"price" : subnets_prices .get (subnet ["netuid" ], 0 )})
1157
+ if not isinstance (prices , SubstrateRequestException ):
1158
+ for subnet in result :
1159
+ subnet .update ({"price" : prices .get (subnet ["netuid" ], 0 )})
1160
+ else :
1161
+ logging .warning (
1162
+ f"Unable to fetch subnet prices for block { block } , block hash { block_hash } "
1163
+ )
1147
1164
1148
1165
return SubnetInfo .list_from_dicts (result )
1149
1166
0 commit comments