fix proompters_1_min again

This commit is contained in:
Cyberes 2023-08-22 23:01:09 -06:00
parent b051f8dd6b
commit 36b793e8a2
2 changed files with 6 additions and 10 deletions

View File

@ -7,13 +7,15 @@ from llm_server import opts
from llm_server.integer import ThreadSafeInteger from llm_server.integer import ThreadSafeInteger
from llm_server.opts import concurrent_gens from llm_server.opts import concurrent_gens
proompters_1_min = 0 # proompters_1_min = 0
concurrent_semaphore = Semaphore(concurrent_gens) concurrent_semaphore = Semaphore(concurrent_gens)
proompts = ThreadSafeInteger(0) proompts = ThreadSafeInteger(0)
start_time = datetime.now() start_time = datetime.now()
class SemaphoreCheckerThread(Thread): class SemaphoreCheckerThread(Thread):
proompters_1_min = 0
def __init__(self, semaphore): def __init__(self, semaphore):
Thread.__init__(self) Thread.__init__(self)
self.semaphore = semaphore self.semaphore = semaphore
@ -22,7 +24,6 @@ class SemaphoreCheckerThread(Thread):
self.daemon = True self.daemon = True
def run(self): def run(self):
global proompters_1_min
while True: while True:
current_semaphore_value = self.semaphore._value current_semaphore_value = self.semaphore._value
if current_semaphore_value < opts.concurrent_gens and current_semaphore_value != self.prev_semaphore_value: if current_semaphore_value < opts.concurrent_gens and current_semaphore_value != self.prev_semaphore_value:
@ -30,6 +31,5 @@ class SemaphoreCheckerThread(Thread):
else: else:
self.values.append(0) self.values.append(0)
self.prev_semaphore_value = current_semaphore_value self.prev_semaphore_value = current_semaphore_value
proompters_1_min = sum(self.values) SemaphoreCheckerThread.proompters_1_min = sum(self.values)
# print(proompters_1_min)
time.sleep(1) time.sleep(1)

View File

@ -7,9 +7,7 @@ from llm_server import opts
from llm_server.routes.v1.generate import concurrent_semaphore from llm_server.routes.v1.generate import concurrent_semaphore
from . import bp from . import bp
from .. import stats from .. import stats
from ..cache import cache from ..stats import SemaphoreCheckerThread
from ..helpers.http import cache_control
from ..stats import proompters_1_min
from ...llm.info import get_running_model from ...llm.info import get_running_model
@ -23,12 +21,10 @@ def get_stats():
else: else:
online = True online = True
# print('-->', proompters_1_min)
return jsonify({ return jsonify({
'stats': { 'stats': {
'proompters_now': opts.concurrent_gens - concurrent_semaphore._value, 'proompters_now': opts.concurrent_gens - concurrent_semaphore._value,
'proompters_1_min': proompters_1_min, 'proompters_1_min': SemaphoreCheckerThread.proompters_1_min,
'total_proompts': stats.proompts.value, 'total_proompts': stats.proompts.value,
'uptime': int((datetime.now() - stats.start_time).total_seconds()), 'uptime': int((datetime.now() - stats.start_time).total_seconds()),
}, },