|
|
@ -5,17 +5,16 @@ 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):
|
|
|
|
"""
|
|
|
|
"""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 ``queue``
|
|
|
|
which in turn creates a RQ job when called. Accepts a ``queue``
|
|
|
|
argument that can be either a ``Queue`` instance or a string denoting
|
|
|
|
instance as an optional argument. For example:
|
|
|
|
the queue name. For example:
|
|
|
|
|
|
|
|
|
|
|
|
@job(queue='default')
|
|
|
|
@job(queue='default')
|
|
|
|
def simple_add(x, y):
|
|
|
|
def simple_add(x, y):
|
|
|
|
return x + y
|
|
|
|
return x + y
|
|
|
|
|
|
|
|
|
|
|
|
simple_add.delay(1, 2) # Puts simple_add function into queue
|
|
|
|
simple_add.delay(1, 2) # Puts simple_add function into queue
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self.queue = queue
|
|
|
|
self.queue = queue
|
|
|
|
self.connection = connection
|
|
|
|
self.connection = connection
|
|
|
|