fix duplicate logging from console printer thread
This commit is contained in:
parent
adc0905c6f
commit
097d614a35
|
@ -4,21 +4,20 @@ import time
|
||||||
|
|
||||||
from llm_server.routes.cache import redis
|
from llm_server.routes.cache import redis
|
||||||
|
|
||||||
|
logger = logging.getLogger('console_printer')
|
||||||
def console_printer():
|
if not logger.handlers:
|
||||||
logger = logging.getLogger('console_printer')
|
|
||||||
handler = logging.StreamHandler()
|
handler = logging.StreamHandler()
|
||||||
handler.setLevel(logging.INFO)
|
handler.setLevel(logging.INFO)
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
formatter = logging.Formatter("%(asctime)s: %(levelname)s:%(name)s - %(message)s")
|
formatter = logging.Formatter("%(asctime)s: %(levelname)s:%(name)s - %(message)s")
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
logger.addHandler(handler)
|
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}')
|
logger.info(f'REQUEST QUEUE -> Processing: {processing_count} | Queued: {queued_ip_count}')
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
from llm_server.workers.printer import start_console_printer
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -183,12 +184,7 @@ def pre_fork(server):
|
||||||
|
|
||||||
# Start background processes
|
# Start background processes
|
||||||
start_workers(opts.concurrent_gens)
|
start_workers(opts.concurrent_gens)
|
||||||
# start_console_printer()
|
start_console_printer()
|
||||||
|
|
||||||
t = threading.Thread(target=console_printer)
|
|
||||||
t.daemon = True
|
|
||||||
t.start()
|
|
||||||
|
|
||||||
start_moderation_workers(opts.openai_moderation_workers)
|
start_moderation_workers(opts.openai_moderation_workers)
|
||||||
MainBackgroundThread().start()
|
MainBackgroundThread().start()
|
||||||
SemaphoreCheckerThread().start()
|
SemaphoreCheckerThread().start()
|
||||||
|
|
Reference in New Issue