Integration rq with pyramid
- allow configuring the redis connection in your
- make sure the redis connection used by RQ is appropriate for the Pyramid application, even if you are running multiple differently configure Pyramid applications within the same process.
- provide a replacement for the standard RQ worker which runs all tasks in a fully configured Pyramid environment.
How to use pyramid_rq
Using pyramid_rq is very easy. The first thing you need to do is add
pyramid_rq to the list of required packages in your
setup(name='my_package', ... install_requires=['pyramid_rq'], ... )
After doing this you will need to reinstall/develop your application or, if you are using buildout, rerun buildout.
The next step is to configure RQ in your application. In your startup code simply add this line:
And that is everything! This will setup a default configuration that assumes you are using a local redis server.
The default configuration assumes that you are using a local redis server
listening on its default port. If your environment is different you can
specify a different configuration in your
.ini-file. This is done using
- The hostname for the redis server. If not specified defaults to
- The TCP port used to connect to the redis server. Defaults to 6379.
- The redis database nmber to use. If not specified this defaults to 1.
All configuration options are available under two keys: either prefixed
rq.redis or by
redis, prefering the
rq.redis key if
present. This is done to allow using the redis configuration in other
places as well, while also making it possible to use a different redis
configuration for RQ.