API¶
Anything in the documentation is part of the public API that Flask-RQ provides, unless otherwise indicated. Anything not documented here is considered internal or private and may change at any time.
- class flask_rq.RQ(app=None)¶
Manage RQ queues and Redis connections for Flask and Quart applications.
- Parameters:
app (Flask | Quart | None) – Call
init_app()with this application.
- init_app(app)¶
Register the extension on an application, creating queues from its
config.- Parameters:
app (Flask | Quart) – The application to register.
- Return type:
None
- get_queue(name='default')¶
Get a specific queue associated with the current application.
The
queueattribute is a shortcut for calling this without an argument to get the default queue.- Parameters:
name (str) – The name associated with the queue.
- Return type:
Queue
- property queue: Queue¶
The default queue associated with the current application.
- make_worker(queues=None, **kwargs)¶
Create a worker for the current application that will watch the configured queues and execute jobs in the application context.
- Parameters:
- Return type:
Worker
- job(f: Callable[[P], R], *, queue: str = 'default') JobWrapper[P, R]¶
- job(*, queue: str = 'default') Callable[[Callable[[P], R]], JobWrapper[P, R]]
Wrap the decorated function to add an
enqueuemethod to it.job.enqueue()is a shortcut forrq.queue.enqueue(job). Can be used as a decorator with or without arguments, or as a function.@rq.job def add(a, b): return a + b @rq.job(queue="math") def sub(a, b): return a - b mul = rq.job(lambda a, b: a * b, queue="math")
- Parameters:
f – The job function. If not given, return a new decorator that uses the other given arguments.
queue – The queue to use to submit this job.
- class flask_rq._job_wrapper.JobWrapper¶
The wrapper returned when using the
RQ.jobdecorator. This class itself is not part of the public API, and should not be imported directly. The methods documented below are part of the public API.- enqueue(*args, **kwargs)¶
Submit the wrapped function to the queue for background execution.
This retains the same static type signature for as the wrapped function, except it returns a
rq.Jobinstance.- Parameters:
args (~P) – Any positional arguments accepted by the wrapped function.
kwargs (~P) – Any keyword arguments accepted by the wrapped function, along with any keyword arguments that can be passed to
rq.Queue.enqueue().
- Return type:
Job
- delay(*args, **kwargs)¶
Submit the wrapped function to the queue for background execution.
- Parameters:
args (~P) – Any positional arguments accepted by the wrapped function.
kwargs (~P) – Any keyword arguments accepted by the wrapped function, along with any keyword arguments that can be passed to
rq.Queue.enqueue().
- Return type:
Job
Deprecated since version 0.3: Renamed to
enqueue(). Will be removed in Flask-RQ 1.0.
- __call__(*args, **kwargs)¶
Call the wrapped function directly.
This retains the same static type signature as the wrapped function.
- Parameters:
args (~P) – Any positional arguments accepted by the wrapped function.
kwargs (~P) – Any keyword arguments accepted by the wrapped function.
- Return type:
R