From 7b434a32eb7b0ef88e730ae909541f2a17120014 Mon Sep 17 00:00:00 2001 From: zhangliyong Date: Fri, 12 Sep 2014 10:16:28 +0700 Subject: [PATCH] Let cleanup_ghosts accept conn argument --- rq/contrib/legacy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rq/contrib/legacy.py b/rq/contrib/legacy.py index 447c002..710c2e3 100644 --- a/rq/contrib/legacy.py +++ b/rq/contrib/legacy.py @@ -11,7 +11,7 @@ from rq import Worker logger = logging.getLogger(__name__) -def cleanup_ghosts(): +def cleanup_ghosts(conn=None): """ RQ versions < 0.3.6 suffered from a race condition where workers, when abruptly terminated, did not have a chance to clean up their worker @@ -21,8 +21,8 @@ def cleanup_ghosts(): This function will clean up any of such legacy ghosted workers. """ - conn = get_current_connection() - for worker in Worker.all(): + conn = conn if conn else get_current_connection() + for worker in Worker.all(connection=conn): if conn._ttl(worker.key) == -1: ttl = worker.default_worker_ttl conn.expire(worker.key, ttl)