|
|
@ -68,7 +68,6 @@ class Worker(object):
|
|
|
|
redis_workers_keys = 'rq:workers'
|
|
|
|
redis_workers_keys = 'rq:workers'
|
|
|
|
death_penalty_class = UnixSignalDeathPenalty
|
|
|
|
death_penalty_class = UnixSignalDeathPenalty
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
def all(cls, connection=None):
|
|
|
|
def all(cls, connection=None):
|
|
|
|
"""Returns an iterable of all Workers.
|
|
|
|
"""Returns an iterable of all Workers.
|
|
|
@ -140,8 +139,7 @@ class Worker(object):
|
|
|
|
if exc_handler is not None:
|
|
|
|
if exc_handler is not None:
|
|
|
|
self.push_exc_handler(exc_handler)
|
|
|
|
self.push_exc_handler(exc_handler)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_queues(self):
|
|
|
|
def validate_queues(self): # noqa
|
|
|
|
|
|
|
|
"""Sanity check for the given queues."""
|
|
|
|
"""Sanity check for the given queues."""
|
|
|
|
if not iterable(self.queues):
|
|
|
|
if not iterable(self.queues):
|
|
|
|
raise ValueError('Argument queues not iterable.')
|
|
|
|
raise ValueError('Argument queues not iterable.')
|
|
|
@ -157,8 +155,7 @@ class Worker(object):
|
|
|
|
"""Returns the Redis keys representing this worker's queues."""
|
|
|
|
"""Returns the Redis keys representing this worker's queues."""
|
|
|
|
return map(lambda q: q.key, self.queues)
|
|
|
|
return map(lambda q: q.key, self.queues)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property # noqa
|
|
|
|
|
|
|
|
def name(self):
|
|
|
|
def name(self):
|
|
|
|
"""Returns the name of the worker, under which it is registered to the
|
|
|
|
"""Returns the name of the worker, under which it is registered to the
|
|
|
|
monitoring system.
|
|
|
|
monitoring system.
|
|
|
@ -201,8 +198,7 @@ class Worker(object):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
setprocname('rq: %s' % (message,))
|
|
|
|
setprocname('rq: %s' % (message,))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def register_birth(self):
|
|
|
|
def register_birth(self): # noqa
|
|
|
|
|
|
|
|
"""Registers its own birth."""
|
|
|
|
"""Registers its own birth."""
|
|
|
|
self.log.debug('Registering birth of worker %s' % (self.name,))
|
|
|
|
self.log.debug('Registering birth of worker %s' % (self.name,))
|
|
|
|
if self.connection.exists(self.key) and \
|
|
|
|
if self.connection.exists(self.key) and \
|
|
|
@ -326,8 +322,7 @@ class Worker(object):
|
|
|
|
signal.signal(signal.SIGINT, request_stop)
|
|
|
|
signal.signal(signal.SIGINT, request_stop)
|
|
|
|
signal.signal(signal.SIGTERM, request_stop)
|
|
|
|
signal.signal(signal.SIGTERM, request_stop)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def work(self, burst=False):
|
|
|
|
def work(self, burst=False): # noqa
|
|
|
|
|
|
|
|
"""Starts the work loop.
|
|
|
|
"""Starts the work loop.
|
|
|
|
|
|
|
|
|
|
|
|
Pops and performs all jobs on the current list of queues. When all
|
|
|
|
Pops and performs all jobs on the current list of queues. When all
|
|
|
|