|
|
@ -12,9 +12,11 @@ class BaseRegistry(object):
|
|
|
|
Each job is stored as a key in the registry, scored by expiration time
|
|
|
|
Each job is stored as a key in the registry, scored by expiration time
|
|
|
|
(unix timestamp).
|
|
|
|
(unix timestamp).
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
key_template = 'rq:registry:{0}'
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, name='default', connection=None):
|
|
|
|
def __init__(self, name='default', connection=None):
|
|
|
|
self.name = name
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
self.key = self.key_template.format(name)
|
|
|
|
self.connection = resolve_connection(connection)
|
|
|
|
self.connection = resolve_connection(connection)
|
|
|
|
|
|
|
|
|
|
|
|
def __len__(self):
|
|
|
|
def __len__(self):
|
|
|
@ -66,10 +68,7 @@ class StartedJobRegistry(BaseRegistry):
|
|
|
|
Jobs are added to registry right before they are executed and removed
|
|
|
|
Jobs are added to registry right before they are executed and removed
|
|
|
|
right after completion (success or failure).
|
|
|
|
right after completion (success or failure).
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
key_template = 'rq:wip:{0}'
|
|
|
|
def __init__(self, name='default', connection=None):
|
|
|
|
|
|
|
|
super(StartedJobRegistry, self).__init__(name, connection)
|
|
|
|
|
|
|
|
self.key = 'rq:wip:{0}'.format(name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cleanup(self, timestamp=None):
|
|
|
|
def cleanup(self, timestamp=None):
|
|
|
|
"""Remove expired jobs from registry and add them to FailedQueue.
|
|
|
|
"""Remove expired jobs from registry and add them to FailedQueue.
|
|
|
@ -105,10 +104,7 @@ class FinishedJobRegistry(BaseRegistry):
|
|
|
|
Registry of jobs that have been completed. Jobs are added to this
|
|
|
|
Registry of jobs that have been completed. Jobs are added to this
|
|
|
|
registry after they have successfully completed for monitoring purposes.
|
|
|
|
registry after they have successfully completed for monitoring purposes.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
key_template = 'rq:finished:{0}'
|
|
|
|
def __init__(self, name='default', connection=None):
|
|
|
|
|
|
|
|
super(FinishedJobRegistry, self).__init__(name, connection)
|
|
|
|
|
|
|
|
self.key = 'rq:finished:{0}'.format(name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cleanup(self, timestamp=None):
|
|
|
|
def cleanup(self, timestamp=None):
|
|
|
|
"""Remove expired jobs from registry.
|
|
|
|
"""Remove expired jobs from registry.
|
|
|
@ -125,10 +121,7 @@ class DeferredJobRegistry(BaseRegistry):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Registry of deferred jobs (waiting for another job to finish).
|
|
|
|
Registry of deferred jobs (waiting for another job to finish).
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
key_template = 'rq:deferred:{0}'
|
|
|
|
def __init__(self, name='default', connection=None):
|
|
|
|
|
|
|
|
super(DeferredJobRegistry, self).__init__(name, connection)
|
|
|
|
|
|
|
|
self.key = 'rq:deferred:{0}'.format(name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cleanup(self):
|
|
|
|
def cleanup(self):
|
|
|
|
"""This method is only here to prevent errors because this method is
|
|
|
|
"""This method is only here to prevent errors because this method is
|
|
|
|