|
|
|
@ -1,6 +1,11 @@
|
|
|
|
|
import importlib
|
|
|
|
|
import redis
|
|
|
|
|
import os
|
|
|
|
|
from functools import partial
|
|
|
|
|
from warnings import warn
|
|
|
|
|
|
|
|
|
|
import redis
|
|
|
|
|
from first import first
|
|
|
|
|
|
|
|
|
|
from rq import use_connection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -32,31 +37,20 @@ def read_config_file(module):
|
|
|
|
|
|
|
|
|
|
def setup_default_arguments(args, settings):
|
|
|
|
|
""" Sets up args from settings or defaults """
|
|
|
|
|
if args.url is None:
|
|
|
|
|
args.url = settings.get('REDIS_URL')
|
|
|
|
|
args.url = first([args.url, settings.get('REDIS_URL'), os.environ.get('RQ_REDIS_URL')])
|
|
|
|
|
|
|
|
|
|
if (args.host or args.port or args.socket or args.db or args.password):
|
|
|
|
|
warn('Host, port, db, password options for Redis will not be '
|
|
|
|
|
'supported in future versions of RQ. '
|
|
|
|
|
'Please use `REDIS_URL` or `--url` instead.', DeprecationWarning)
|
|
|
|
|
|
|
|
|
|
if args.host is None:
|
|
|
|
|
args.host = settings.get('REDIS_HOST', 'localhost')
|
|
|
|
|
|
|
|
|
|
if args.port is None:
|
|
|
|
|
args.port = int(settings.get('REDIS_PORT', 6379))
|
|
|
|
|
else:
|
|
|
|
|
args.port = int(args.port)
|
|
|
|
|
|
|
|
|
|
socket = settings.get('REDIS_SOCKET', False)
|
|
|
|
|
if args.socket is None and socket:
|
|
|
|
|
args.socket = socket
|
|
|
|
|
|
|
|
|
|
if args.db is None:
|
|
|
|
|
args.db = settings.get('REDIS_DB', 0)
|
|
|
|
|
strict_first = partial(first, key=lambda obj: obj is not None)
|
|
|
|
|
|
|
|
|
|
if args.password is None:
|
|
|
|
|
args.password = settings.get('REDIS_PASSWORD', None)
|
|
|
|
|
args.host = strict_first([args.host, settings.get('REDIS_HOST'), os.environ.get('RQ_REDIS_HOST'), 'localhost'])
|
|
|
|
|
args.port = int(strict_first([args.port, settings.get('REDIS_PORT'), os.environ.get('RQ_REDIS_PORT'), 6379]))
|
|
|
|
|
args.socket = strict_first([args.socket, settings.get('REDIS_SOCKET'), os.environ.get('RQ_REDIS_SOCKET'), False])
|
|
|
|
|
args.db = strict_first([args.db, settings.get('REDIS_DB'), os.environ.get('RQ_REDIS_DB'), 0])
|
|
|
|
|
args.password = strict_first([args.password, settings.get('REDIS_PASSWORD'), os.environ.get('RQ_REDIS_PASSWORD')])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setup_redis(args):
|
|
|
|
|