diff --git a/rq/suspension.py b/rq/suspension.py index 93152b9..3e96014 100644 --- a/rq/suspension.py +++ b/rq/suspension.py @@ -1,8 +1,14 @@ WORKERS_SUSPENDED = 'rq:suspended' -def is_suspended(connection): - return connection.exists(WORKERS_SUSPENDED) +def is_suspended(connection, worker=None): + with connection.pipeline() as pipeline: + if worker is not None: + worker.heartbeat(pipeline=pipeline) + pipeline.exists(WORKERS_SUSPENDED) + # pipeline returns a list of responses + # https://github.com/andymccurdy/redis-py#pipelines + return pipeline.execute()[-1] def suspend(connection, ttl=None): diff --git a/rq/worker.py b/rq/worker.py index dd9d0bc..8dd855a 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -416,7 +416,7 @@ class Worker(object): before_state = None notified = False - while not self._stop_requested and is_suspended(self.connection): + while not self._stop_requested and is_suspended(self.connection, self): if burst: self.log.info('Suspended in burst mode, exiting')