Merge pull request #56 from mattdennewitz/master

Class methods use given class, not hard-coded class
main
Vincent Driessen 13 years ago
commit 1d27223069

@ -49,7 +49,7 @@ class Job(object):
keyword arguments. keyword arguments.
""" """
connection = kwargs.pop('connection', None) connection = kwargs.pop('connection', None)
job = Job(connection=connection) job = cls(connection=connection)
job._func_name = '%s.%s' % (func.__module__, func.__name__) job._func_name = '%s.%s' % (func.__module__, func.__name__)
job._args = args job._args = args
job._kwargs = kwargs job._kwargs = kwargs
@ -89,7 +89,7 @@ class Job(object):
"""Fetches a persisted job from its corresponding Redis key and """Fetches a persisted job from its corresponding Redis key and
instantiates it. instantiates it.
""" """
job = Job(id, connection=connection) job = cls(id, connection=connection)
job.refresh() job.refresh()
return job return job

@ -40,7 +40,7 @@ class Queue(object):
if not queue_key.startswith(prefix): if not queue_key.startswith(prefix):
raise ValueError('Not a valid RQ queue key: %s' % (queue_key,)) raise ValueError('Not a valid RQ queue key: %s' % (queue_key,))
name = queue_key[len(prefix):] name = queue_key[len(prefix):]
return Queue(name, connection=connection) return cls(name, connection=connection)
def __init__(self, name='default', default_timeout=None, connection=None): def __init__(self, name='default', default_timeout=None, connection=None):
if connection is None: if connection is None:
@ -209,7 +209,7 @@ class Queue(object):
if result is None: if result is None:
return None return None
queue_key, job_id = result queue_key, job_id = result
queue = Queue.from_queue_key(queue_key, connection=connection) queue = cls.from_queue_key(queue_key, connection=connection)
try: try:
job = Job.fetch(job_id, connection=connection) job = Job.fetch(job_id, connection=connection)
except NoSuchJobError: except NoSuchJobError:

@ -73,7 +73,7 @@ class Worker(object):
return None return None
name = worker_key[len(prefix):] name = worker_key[len(prefix):]
worker = Worker([], name) worker = cls([], name)
queues = conn.hget(worker.key, 'queues') queues = conn.hget(worker.key, 'queues')
worker._state = conn.hget(worker.key, 'state') or '?' worker._state = conn.hget(worker.key, 'state') or '?'
if queues: if queues:

Loading…
Cancel
Save