|
|
|
@ -12,7 +12,7 @@ from .queue import Queue
|
|
|
|
|
|
|
|
|
|
class job(object):
|
|
|
|
|
def __init__(self, queue, connection=None, timeout=None,
|
|
|
|
|
result_ttl=DEFAULT_RESULT_TTL):
|
|
|
|
|
result_ttl=DEFAULT_RESULT_TTL, ttl=None):
|
|
|
|
|
"""A decorator that adds a ``delay`` method to the decorated function,
|
|
|
|
|
which in turn creates a RQ job when called. Accepts a required
|
|
|
|
|
``queue`` argument that can be either a ``Queue`` instance or a string
|
|
|
|
@ -28,6 +28,7 @@ class job(object):
|
|
|
|
|
self.connection = connection
|
|
|
|
|
self.timeout = timeout
|
|
|
|
|
self.result_ttl = result_ttl
|
|
|
|
|
self.ttl = ttl
|
|
|
|
|
|
|
|
|
|
def __call__(self, f):
|
|
|
|
|
@wraps(f)
|
|
|
|
@ -38,6 +39,7 @@ class job(object):
|
|
|
|
|
queue = self.queue
|
|
|
|
|
depends_on = kwargs.pop('depends_on', None)
|
|
|
|
|
return queue.enqueue_call(f, args=args, kwargs=kwargs,
|
|
|
|
|
timeout=self.timeout, result_ttl=self.result_ttl, depends_on=depends_on)
|
|
|
|
|
timeout=self.timeout, result_ttl=self.result_ttl,
|
|
|
|
|
ttl=self.ttl, depends_on=depends_on)
|
|
|
|
|
f.delay = delay
|
|
|
|
|
return f
|
|
|
|
|