You can additionally schedule jobs to run at a certain time, after a certain
timespan or by a cron-like plan:

@rq.jobdefadd(x,y):returnx+y# queue job in 60 secondsadd.schedule(timedelta(seconds=60),1,2)# queue job at a certain datetime (UTC!)add.schedule(datetime(2016,12,31,23,59,59),1,2)# queue job in 14 days and then repeat once 14 days lateradd.schedule(timedelta(days=14),1,2,repeat=1)# queue job every day at noon (UTC!)add.cron('0 0 12 * * ?','add-one-two',1,2)

get_worker

Returns a worker for default queue or specific queues for names given as arguments:

fromflask_rq2importRQrq=RQ()# Creates a worker that handle jobs in ``default`` queue.default_worker=rq.get_worker()default_worker.work(burst=True)# Creates a worker that handle jobs in both ``simple`` and ``low`` queues.low_n_simple_worker=rq.get_worker('low','simple')low_n_simple_worker.work(burst=True)

CLI support

Flask CLI

For the Flask CLI to work it’s recommended to install the Flask-CLI package
since it contains a import shim to automatically import CLI code from
Flask in case >= 1.0 is installed. That means this is the most future proof
option for you.

The rest happens automatically: a new rq subcommand will be added to the
flask command that wraps RQ’s own rq CLI tool using the Flask
configuration values.

Please call flask rq --help for more information, assuming
you’ve set the FLASK_APP environment variable to the Flask app path.

You can install the dependencies for this using this shortcut:

pip install Flask-RQ2[cli]

Flask-Script

Flask-Script works a bit different and requires you to manually register a
command manager with the main script manager. For example: