From b443df79470982724a042fb2ab5737c220d73284 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 8 Jul 2018 12:13:43 +0200 Subject: [PATCH] Parametrized the HTTP backend Redis object by using the same configuration used on the Redis backend --- platypush/backend/http/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/platypush/backend/http/__init__.py b/platypush/backend/http/__init__.py index 1eaaa2707..bebdf3dc3 100644 --- a/platypush/backend/http/__init__.py +++ b/platypush/backend/http/__init__.py @@ -13,6 +13,7 @@ from flask import Flask, abort, jsonify, request as http_request, render_templat from redis import Redis from platypush.config import Config +from platypush.context import get_backend from platypush.message import Message from platypush.message.event import Event, StopEvent from platypush.message.event.web.widget import WidgetUpdateEvent @@ -109,7 +110,17 @@ class HttpBackend(Backend): self.websocket_thread = None self.redis_thread = None self.active_websockets = set() - self.redis = Redis() + self.redis = self._get_redis() + + + def _get_redis(self): + redis_backend = get_backend('redis') + if not redis_backend: + raise RuntimeError('Redis backend not configured') + + redis_args = get_backend('redis').redis_args + redis = Redis(**redis_args) + return redis def send_message(self, msg):