Skip to content

Commit

Permalink
Remove custom Redis connection code in favor of redis.from_url (getre…
Browse files Browse the repository at this point in the history
  • Loading branch information
arikfr authored and harveyrendell committed Nov 14, 2019
1 parent 52fefe0 commit f94270d
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions redash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,10 @@ def setup_logging():
logging.getLogger(name).setLevel("ERROR")


def create_redis_connection():
logging.debug("Creating Redis connection (%s)", settings.REDIS_URL)
redis_url = urlparse.urlparse(settings.REDIS_URL)

if redis_url.scheme == 'redis+socket':
qs = urlparse.parse_qs(redis_url.query)
if 'virtual_host' in qs:
db = qs['virtual_host'][0]
else:
db = 0

client = redis.StrictRedis(unix_socket_path=redis_url.path, db=db)
else:
use_ssl = redis_url.scheme == 'rediss'

if redis_url.path:
redis_db = redis_url.path[1]
else:
redis_db = 0
# Redis passwords might be quoted with special characters
redis_password = redis_url.password and urllib.unquote(redis_url.password)
client = redis.StrictRedis(
host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_password,
ssl=use_ssl)

return client


setup_logging()

redis_connection = create_redis_connection()

redis_connection = redis.from_url(settings.REDIS_URL)
mail = Mail()

migrate = Migrate()

statsd_client = StatsClient(host=settings.STATSD_HOST, port=settings.STATSD_PORT, prefix=settings.STATSD_PREFIX)

limiter = Limiter(key_func=get_ipaddr, storage_uri=settings.LIMITER_STORAGE)

0 comments on commit f94270d

Please sign in to comment.