From 91a18c2313771cb3e1c027b10b0773234465df60 Mon Sep 17 00:00:00 2001 From: christianEQ Date: Wed, 17 Mar 2021 16:10:06 +0000 Subject: [PATCH] working blpop test in monkey Former-commit-id: 21af13c2a38741ad9e036fad42b23ea2454ac33c --- monkey/monkey.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/monkey/monkey.py b/monkey/monkey.py index e1b8fbb0e..07f157961 100644 --- a/monkey/monkey.py +++ b/monkey/monkey.py @@ -181,8 +181,7 @@ def handle_blpop_response(c, resp=None): global ops if resp != None: ops['blpop'] += 1 - else: - c.blpop("list_" + getrandomkey(), callback=handle_blpop_response) + c.blpop("list_" + getrandomkey(), callback=handle_blpop_response) def handle_set_response(c, resp=None): global ops @@ -214,7 +213,7 @@ def stats_thread(): i = 0 while not g_exit and not (runtime and i > runtime): time.sleep(1) - print("Ops per second: " + str(ops)) + print("Ops per second: " + str({k:v for (k,v) in ops.items() if v})) #print(f"Blocked threads: {len(list(filter(lambda x: x.blocked, clients)))}") clear_ops() i += 1 @@ -229,7 +228,7 @@ def flush_db_sync(): def init_blocking(): global clients - if numkeys > 5 * numclients: + if numkeys > 100 * numclients: print("WARNING: High ratio of keys to clients. Most lpushes will not be popped and unblocking will take a long time!") for i in range(numclients): clients.append(Client('127.0.0.1', 6379)) @@ -265,6 +264,10 @@ def main(test, flush): except KeyError: print(f"Test \"{test}\" not found. Exiting...") exit() + except ConnectionRefusedError: + print("Could not connect to server. Is it running?") + print("Exiting...") + exit() threading.Thread(target=stats_thread).start() asyncore.loop()