mirror of https://github.com/rq/rq.git
fix_cleanup_ghosts_by_using_configured_worker_class (#1988)
Signed-off-by: Simó Albert i Beltran <sim6@bona.gent>
This commit is contained in:
parent
626378cb32
commit
235a87d01e
|
@ -256,7 +256,7 @@ def worker(
|
|||
setup_loghandlers_from_args(verbose, quiet, date_format, log_format)
|
||||
|
||||
try:
|
||||
cleanup_ghosts(cli_config.connection)
|
||||
cleanup_ghosts(cli_config.connection, worker_class=cli_config.worker_class)
|
||||
exception_handlers = []
|
||||
for h in exception_handler:
|
||||
exception_handlers.append(import_attribute(h))
|
||||
|
|
|
@ -5,7 +5,7 @@ from rq import Worker, get_current_connection
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def cleanup_ghosts(conn=None):
|
||||
def cleanup_ghosts(conn=None, worker_class=Worker):
|
||||
"""
|
||||
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
|
||||
|
@ -16,7 +16,7 @@ def cleanup_ghosts(conn=None):
|
|||
This function will clean up any of such legacy ghosted workers.
|
||||
"""
|
||||
conn = conn if conn else get_current_connection()
|
||||
for worker in Worker.all(connection=conn):
|
||||
for worker in worker_class.all(connection=conn):
|
||||
if conn.ttl(worker.key) == -1:
|
||||
ttl = worker.worker_ttl
|
||||
conn.expire(worker.key, ttl)
|
||||
|
|
Loading…
Reference in New Issue