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.opts import concurrent_gens
proompters_1_min = 0
# proompters_1_min = 0
concurrent_semaphore = Semaphore(concurrent_gens)
proompts = ThreadSafeInteger(0)
start_time = datetime.now()
class SemaphoreCheckerThread(Thread):
proompters_1_min = 0
def __init__(self, semaphore):
Thread.__init__(self)
self.semaphore = semaphore
@ -22,7 +24,6 @@ class SemaphoreCheckerThread(Thread):
self.daemon = True
def run(self):
global proompters_1_min
while True:
current_semaphore_value = self.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:
self.values.append(0)
self.prev_semaphore_value = current_semaphore_value
proompters_1_min = sum(self.values)
# print(proompters_1_min)
SemaphoreCheckerThread.proompters_1_min = sum(self.values)
time.sleep(1)

View File

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