diff --git a/services/rediscache.py b/services/rediscache.py index 92f6ae0..da69df1 100644 --- a/services/rediscache.py +++ b/services/rediscache.py @@ -53,14 +53,11 @@ class RedisCache: pubsub = self._client.pubsub() await pubsub.subscribe(channel) - try: - while True: - message = await pubsub.get_message() - if message: - yield json.loads(message['data']) - await asyncio.sleep(0.1) - finally: - await pubsub.unsubscribe(channel) + while True: + message = await pubsub.get_message() + if message and isinstance(message['data'], (str, bytes, bytearray)): + yield json.loads(message['data']) + await asyncio.sleep(0.1) redis = RedisCache()