Oscar Wang commited on
Commit
39b1b34
·
verified ·
1 Parent(s): 3421757

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -19,18 +19,16 @@ state = {
19
  }
20
 
21
  @retry(stop=stop_after_attempt(3), wait=wait_fixed(2), retry=retry_if_exception_type(httpx.ReadTimeout))
22
- def get_token_count(client, api_name):
23
- url = f"{client.base_url}{api_name}"
24
- response = httpx.get(url, timeout=10.0)
25
- response.raise_for_status() # Raise an exception for HTTP errors
26
- return int(response.json())
27
 
28
  def monitor_growth():
29
  while True:
30
  try:
31
- curr_count1 = get_token_count(client1, "/update_token_display")
32
- curr_count2 = get_token_count(client2, "/update_token_display")
33
- curr_count3 = get_token_count(client3, "/update_token_display")
34
  growth_speed1 = curr_count1 - state["prev_count1"]
35
  growth_speed2 = curr_count2 - state["prev_count2"]
36
  growth_speed3 = curr_count3 - state["prev_count3"]
 
19
  }
20
 
21
  @retry(stop=stop_after_attempt(3), wait=wait_fixed(2), retry=retry_if_exception_type(httpx.ReadTimeout))
22
+ def get_token_count(client):
23
+ result = client.predict(api_name="/update_token_display")
24
+ return int(result)
 
 
25
 
26
  def monitor_growth():
27
  while True:
28
  try:
29
+ curr_count1 = get_token_count(client1)
30
+ curr_count2 = get_token_count(client2)
31
+ curr_count3 = get_token_count(client3)
32
  growth_speed1 = curr_count1 - state["prev_count1"]
33
  growth_speed2 = curr_count2 - state["prev_count2"]
34
  growth_speed3 = curr_count3 - state["prev_count3"]