Merge pull request #896 from theodesp/Issue-812

Fixed #812 - Send heartbeat during suspension check
main
Selwin Ong 7 years ago committed by GitHub
commit 32747b59fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

Loading…
Cancel
Save