From 6603f64757e01c62ef7a6baad9e53da183f2af1b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 20 Nov 2018 14:24:14 +0000 Subject: [PATCH] Enforced cast to string for any object posted to the Redis bus --- platypush/backend/http/__init__.py | 4 ++-- platypush/backend/redis.py | 1 + platypush/plugins/adafruit/io.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/platypush/backend/http/__init__.py b/platypush/backend/http/__init__.py index cb825f654a..185a51d795 100644 --- a/platypush/backend/http/__init__.py +++ b/platypush/backend/http/__init__.py @@ -149,7 +149,7 @@ class HttpBackend(Backend): redis = self._get_redis() if redis: - redis.rpush(self.redis_queue, stop_evt) + redis.rpush(self.redis_queue, str(stop_evt)) if self.server_proc: self.server_proc.terminate() @@ -284,7 +284,7 @@ class HttpBackend(Backend): redis = self._get_redis() if redis: - redis.rpush(self.redis_queue, event) + redis.rpush(self.redis_queue, str(event)) return jsonify({ 'status': 'ok' }) @app.route('/static/', methods=['GET']) diff --git a/platypush/backend/redis.py b/platypush/backend/redis.py index 352f921598..3d4dd0e06e 100644 --- a/platypush/backend/redis.py +++ b/platypush/backend/redis.py @@ -35,6 +35,7 @@ class RedisBackend(Backend): def send_message(self, msg, queue_name=None): + msg = str(msg) if queue_name: self.redis.rpush(queue_name, msg) else: diff --git a/platypush/plugins/adafruit/io.py b/platypush/plugins/adafruit/io.py index 0a5b8d1ad6..0ce56dc345 100644 --- a/platypush/plugins/adafruit/io.py +++ b/platypush/plugins/adafruit/io.py @@ -1,5 +1,6 @@ import ast import statistics +import json import time from threading import Thread, Lock @@ -141,7 +142,7 @@ class AdafruitIoPlugin(Plugin): else: # Otherwise send it to the Redis queue to be picked up by the throttler thread redis = self._get_redis() - redis.rpush(self._DATA_THROTTLER_QUEUE, {feed:value}) + redis.rpush(self._DATA_THROTTLER_QUEUE, json.dumps({feed:value})) @action