This commit is contained in:
Cyberes 2023-10-05 17:00:35 -06:00
parent 08df52a4fd
commit 27e461c76b
3 changed files with 8 additions and 1 deletions

View File

@ -50,6 +50,11 @@ class RedisPriorityQueue:
return item return item
time.sleep(0.1) # wait for something to be added to the queue time.sleep(0.1) # wait for something to be added to the queue
def print_all_items(self):
items = self.redis.zrange('queue', 0, -1)
for item in items:
print(item.decode('utf-8'))
def increment_ip_count(self, client_ip: str, redis_key): def increment_ip_count(self, client_ip: str, redis_key):
self.redis.hincrby(redis_key, client_ip, 1) self.redis.hincrby(redis_key, client_ip, 1)

View File

@ -25,4 +25,6 @@ def console_printer():
processing_count += redis.get(k, default=0, dtype=int) processing_count += redis.get(k, default=0, dtype=int)
backends = [k for k, v in cluster_config.all().items() if v['online']] backends = [k for k, v in cluster_config.all().items() if v['online']]
logger.info(f'REQUEST QUEUE -> Processing: {processing_count} | Queued: {len(priority_queue)} | Backends Online: {len(backends)}') logger.info(f'REQUEST QUEUE -> Processing: {processing_count} | Queued: {len(priority_queue)} | Backends Online: {len(backends)}')
priority_queue.print_all_items()
print('============================')
time.sleep(10) time.sleep(10)

View File

@ -53,4 +53,4 @@ def start_background():
t = Thread(target=db_logger) t = Thread(target=db_logger)
t.daemon = True t.daemon = True
t.start() t.start()
print('Started background logger') print('Started background logger.')