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

@ -40,7 +40,7 @@ class Queue(object):
if not queue_key.startswith(prefix):
raise ValueError('Not a valid RQ queue key: %s' % (queue_key,))
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):
if connection is None:
@ -209,7 +209,7 @@ class Queue(object):
if result is None:
return None
queue_key, job_id = result
queue = Queue.from_queue_key(queue_key, connection=connection)
queue = cls.from_queue_key(queue_key, connection=connection)
try:
job = Job.fetch(job_id, connection=connection)
except NoSuchJobError:

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

Loading…
Cancel
Save