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
This commit is contained in:
Selwin Ong 2024-12-23 19:58:25 +07:00 committed by GitHub
parent 9e138dbfaf
commit dd95a761a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -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()