mirror of https://github.com/rq/rq.git
Fixed #812 - Send heartbeat during suspension check
This commit is contained in:
parent
92c88d3f4d
commit
f226d38603
|
@ -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):
|
||||||
|
|
|
@ -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')
|
||||||
|
|
Loading…
Reference in New Issue