-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathqueue_config.py
30 lines (23 loc) · 967 Bytes
/
queue_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
""" Setup for the Huey task queue. """
# pylint: disable=invalid-name,ungrouped-imports,unused-import
from os import environ
from huey import RedisHuey, SqliteHuey
# run consumer via:
# huey_consumer.py app.huey
# from the root of the app directory
# ------------------------------------------------------
# Huey task config
# ------------------------------------------------------
# Redis is the preferred Huey backend
REDIS_URL = environ.get('REDIS_URL', None)
if REDIS_URL:
# Heroku/Redis integration now defaults to requiring SSL certs
if not REDIS_URL.endswith('?ssl_cert_reqs=none'):
REDIS_URL += '?ssl_cert_reqs=none'
huey = RedisHuey(url=REDIS_URL)
# But in dev environments, fall back to SqliteHuey if Redis is not available
else:
# peewee is required for SqliteHuey
# If this import fails, install peewee directly. Don't add to requirements.txt.
import peewee
huey = SqliteHuey(filename='huey.db', immediate=True)