From 4ebdda80f979b4338e27bb8e651d8d963a14438f Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 8 Jul 2018 12:24:33 +0200 Subject: [PATCH] More robust support for Redis configuration in web socket server --- .travis.requirements | 1 + platypush/backend/http/__init__.py | 7 +++++-- platypush/context/__init__.py | 2 +- tests/etc/config.yaml | 3 --- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.requirements b/.travis.requirements index 5a7738ab..ecf71104 100644 --- a/.travis.requirements +++ b/.travis.requirements @@ -4,3 +4,4 @@ requests flask redis python-dateutil +websockets diff --git a/platypush/backend/http/__init__.py b/platypush/backend/http/__init__.py index bebdf3dc..7ce70153 100644 --- a/platypush/backend/http/__init__.py +++ b/platypush/backend/http/__init__.py @@ -116,9 +116,12 @@ class HttpBackend(Backend): def _get_redis(self): redis_backend = get_backend('redis') if not redis_backend: - raise RuntimeError('Redis backend not configured') + self.logger.warning('Redis backend not configured - some ' + + 'web server features may not be working properly') + redis_args = {} + else: + redis_args = redis_backend.redis_args - redis_args = get_backend('redis').redis_args redis = Redis(**redis_args) return redis diff --git a/platypush/context/__init__.py b/platypush/context/__init__.py index ef2142b7..3b1c1e10 100644 --- a/platypush/context/__init__.py +++ b/platypush/context/__init__.py @@ -56,7 +56,7 @@ def get_backend(name): """ Returns the backend instance identified by name if it exists """ global backends - return backends[name] + return backends.get('name') def get_plugin(plugin_name, reload=False): diff --git a/tests/etc/config.yaml b/tests/etc/config.yaml index fbbf7580..e97c1bb2 100644 --- a/tests/etc/config.yaml +++ b/tests/etc/config.yaml @@ -1,6 +1,3 @@ -backend.redis: - disabled: False - backend.http: port: 8123 disable_websocket: True