Fixed #812 - Send heartbeat during suspension check

This commit is contained in:
Theo 2017-10-24 09:32:10 +01:00
parent 92c88d3f4d
commit f226d38603
2 changed files with 9 additions and 3 deletions

View File

@ -1,8 +1,14 @@
WORKERS_SUSPENDED = 'rq:suspended' WORKERS_SUSPENDED = 'rq:suspended'
def is_suspended(connection): def is_suspended(connection, worker=None):
return connection.exists(WORKERS_SUSPENDED) 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): def suspend(connection, ttl=None):

View File

@ -416,7 +416,7 @@ class Worker(object):
before_state = None before_state = None
notified = False 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: if burst:
self.log.info('Suspended in burst mode, exiting') self.log.info('Suspended in burst mode, exiting')