fix duplicate logging from console printer thread

This commit is contained in:
Cyberes 2023-09-27 21:28:25 -06:00
parent adc0905c6f
commit 097d614a35
2 changed files with 9 additions and 14 deletions

View File

@ -4,21 +4,20 @@ import time
from llm_server.routes.cache import redis
def console_printer():
logger = logging.getLogger('console_printer')
logger = logging.getLogger('console_printer')
if not logger.handlers:
handler = logging.StreamHandler()
handler.setLevel(logging.INFO)
logger.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s: %(levelname)s:%(name)s - %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
while True:
queued_ip_count = redis.get_dict('queued_ip_count')
queued_ip_count = sum([v for k, v in queued_ip_count.items()])
processing_ips = redis.get_dict('processing_ips')
processing_count = sum([v for k, v in processing_ips.items()])
def console_printer():
while True:
queued_ip_count = sum([v for k, v in redis.get_dict('queued_ip_count').items()])
processing_count = sum([v for k, v in redis.get_dict('processing_ips').items()])
logger.info(f'REQUEST QUEUE -> Processing: {processing_count} | Queued: {queued_ip_count}')
time.sleep(10)

View File

@ -5,6 +5,7 @@ try:
except ImportError:
pass
from llm_server.workers.printer import start_console_printer
import os
import re
import sys
@ -183,12 +184,7 @@ def pre_fork(server):
# Start background processes
start_workers(opts.concurrent_gens)
# start_console_printer()
t = threading.Thread(target=console_printer)
t.daemon = True
t.start()
start_console_printer()
start_moderation_workers(opts.openai_moderation_workers)
MainBackgroundThread().start()
SemaphoreCheckerThread().start()