Package: tgext.rq
tgext.rqtgext.rq is a TurboGears2 extension that simplify rq usage for async jobs.TLDRInstallpip install tgext.rq #or

#setup.py
install_requires = [
    "TurboGears2 >= 2.4.3",
    "rq",
    ...,
    "tgext.rq"Plug into TurboGears:#config/app_cfg.py

import tgext.rq
tgext.rq.plugme(base_config)Add configs:#development.ini

redis.url = redis://127.0.0.1:6379/0
tgext.rq.application_queues_module = app.workers.queue
tgext.rq.application_queues_function = application_queuesProvide a method so tgext.rq know all queues that your application uses:#app.workers.queue.py

def application_queues():
  return ['high_priority', 'default_priority', 'low_priority']Run worker:gearbox rqInstallingAdd tgext.rq to yoursetup.py, insideinstall_requires, something like:#setup.py

install_requires = [
    "TurboGears2 >= 2.4.3",
    "rq",
    ...,
    "tgext.rq"or install via pypi:pip install tgext.rqEnablingTo enable tgext.rq put inside your applicationconfig/app_cfg.pythe following:#config/app_cfg.py

import tgext.rq
tgext.rq.plugme(base_config)ConfigurationAll configurations listed here should be done on tg .ini files, likedevelopment.iniorproduction.iniRedis URL#development.ini

redis.url = redis://USERNAME:PASSWORD@IP.ADDRESS.0.1:6379/DATABASE_NUMBER
redis.url = redis://user:test@127.0.0.1:6379/0
redis.url = redis://127.0.0.1:6379/0
redis.url = redis://redis/0 #If you use docker-compose to up redisThis config is required.Queuestgext.rq needs to know what queues it should listen and your application have to
supply a module and function to do that. For example:Imagine that your application have the following module:app.workers.queue.py:#app.workers.queue.py

def application_queues():
  return ['high_priority', 'default_priority', 'low_priority']You need to set these configs:#development.ini

tgext.rq.application_queues_module = app.workers.queue
tgext.rq.application_queues_function = application_queuesps: For now, only modules are supported. No classes.This config is required.Optional configs#development.ini

tgext.rq.default_job_timeout = 180 #default value is 180.Run RQtgext.rq provides a tg command to run a rq worker:gearbox rq -c production.inior using the default development.ini file:gearbox rqMultithreding with Geventtgext.rq comes with options to use a gevent worker to enable more concurrency on
job execution, to enable first add gevent toinstall_requiresonsetup.py#setup.py

install_requires = [
    "TurboGears2 >= 2.4.3",
    "rq",
    ...,
    "tgext.rq >= 0.0.7",
    "gevent >= v1.1.2"Then configure tgext.rq to use GeventWorker class:#development.ini

tgext.rq.worker_class = GeventWorker #default value is: Worker
tgext.rq.gevent_pool_size = 3 #default value is: 20If you receive any errors related to gevent patches, like:super(SSLContext, SSLContext).options.__set__(self, value) [Previous line repeated 473 more times] RecursionError: maximum recursion depth exceededYou need to patch manually your application before it loads, add these lines
before everything else onapp_cfg.pyfrom gevent import monkey
monkey.patch_all()ContributionsFuture Needs:testsmore rq config options[add your needs here]PRs are welcome!ThanksGeventWorker is based on thisgithub project: mikeabrahamsen/rq-gevent-workerHow to upload to PipThis section is for the maintainer to remember how to upload to pypi.
Move along.python setup.py sdist
pip install twine
twine upload dist/*