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