From dd95a761a9906c684076ab76c66cc78a07405dee Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Mon, 23 Dec 2024 19:58:25 +0700 Subject: [PATCH] Try to fix flaky pubsub test (#2165) * Try to fix flaky pubsub test * Print client [addr] * Catch ResponseError when trying to kill pubsub thread * Fix import ordering --- tests/test_commands.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index 32cd0ece..14d91230 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -3,6 +3,7 @@ from multiprocessing import Process from unittest import mock from redis import Redis +from redis.exceptions import ResponseError from rq import Queue, Worker from rq.command import send_command, send_kill_horse_command, send_shutdown_command, send_stop_job_command @@ -44,8 +45,12 @@ class TestCommands(RQTestCase): assert worker.pubsub_thread.is_alive() + # Kill the Redis connection for client in connection.client_list(): - connection.client_kill(client['addr']) + try: + connection.client_kill(client['addr']) + except ResponseError: + pass time.sleep(0.0) # Allow other threads to run assert worker.pubsub_thread.is_alive()