alex n commited on
Commit
02fb8b0
Β·
1 Parent(s): ec470e7
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -46,14 +46,14 @@ def get_validator_data() -> pd.DataFrame:
46
  # Get Step and Range from endpoints
47
  try:
48
  axon_endpoint = f"http://{validator_info['Axon']}"
49
- step_response = requests.get(f"{axon_endpoint}/step", timeout=5)
50
  step_response.raise_for_status()
51
  validator_info['Step'] = step_response.json()
52
 
53
  bits_response = requests.get(
54
  f"{axon_endpoint}/bits",
55
  headers={"range": "bytes=-1"},
56
- timeout=5
57
  )
58
  bits_response.raise_for_status()
59
  binary_string = ''.join(format(byte, '08b') for byte in bits_response.content)
@@ -61,9 +61,11 @@ def get_validator_data() -> pd.DataFrame:
61
  validator_info['API'] = '<span class="api-status api-up">βœ…</span>' if bits_response.ok else '<span class="api-status api-down">❌</span>'
62
 
63
  except requests.Timeout:
64
- print(f"Timeout while connecting to {axon_endpoint}")
65
  except Exception as e:
66
- print(f"Error connecting to {axon_endpoint}: {e}")
 
 
67
 
68
  try:
69
  last_update = int(metagraph.last_update[uid])
 
46
  # Get Step and Range from endpoints
47
  try:
48
  axon_endpoint = f"http://{validator_info['Axon']}"
49
+ step_response = requests.get(f"{axon_endpoint}/step", timeout=(2, 3))
50
  step_response.raise_for_status()
51
  validator_info['Step'] = step_response.json()
52
 
53
  bits_response = requests.get(
54
  f"{axon_endpoint}/bits",
55
  headers={"range": "bytes=-1"},
56
+ timeout=(2, 3)
57
  )
58
  bits_response.raise_for_status()
59
  binary_string = ''.join(format(byte, '08b') for byte in bits_response.content)
 
61
  validator_info['API'] = '<span class="api-status api-up">βœ…</span>' if bits_response.ok else '<span class="api-status api-down">❌</span>'
62
 
63
  except requests.Timeout:
64
+ validator_info['API'] = '<span class="api-status api-down">❌</span>'
65
  except Exception as e:
66
+ if not isinstance(e, requests.Timeout):
67
+ print(f"Error connecting to {axon_endpoint}: {str(e)}")
68
+ validator_info['API'] = '<span class="api-status api-down">❌</span>'
69
 
70
  try:
71
  last_update = int(metagraph.last_update[uid])