diff --git a/llm_server/workers/printer.py b/llm_server/workers/printer.py index aa45ccf..40d3c88 100644 --- a/llm_server/workers/printer.py +++ b/llm_server/workers/printer.py @@ -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) diff --git a/server.py b/server.py index df171ae..548c6bf 100644 --- a/server.py +++ b/server.py @@ -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()