emozilla commited on
Commit
2eaa7de
·
1 Parent(s): b0b6a82

add retry to getting tao price

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -68,8 +68,15 @@ class ModelData:
68
  emission=emission
69
  )
70
 
71
- def get_tao_price():
72
- return float(requests.get("https://api.kucoin.com/api/v1/market/stats?symbol=TAO-USDT").json()["data"]["last"])
 
 
 
 
 
 
 
73
 
74
  def print_validator_weights(metagraph: bt.metagraph):
75
  for uid in metagraph.uids.tolist():
 
68
  emission=emission
69
  )
70
 
71
+ def get_tao_price() -> float:
72
+ for i in range(0, METAGRAPH_RETRIES):
73
+ try:
74
+ return float(requests.get("https://api.kucoin.com/api/v1/market/stats?symbol=TAO-USDT").json()["data"]["last"])
75
+ except:
76
+ if i == METAGRAPH_RETRIES - 1:
77
+ raise
78
+ time.sleep(METAGRAPH_DELAY_SECS)
79
+ raise RuntimeError()
80
 
81
  def print_validator_weights(metagraph: bt.metagraph):
82
  for uid in metagraph.uids.tolist():