From 05079c143c562b74abe1e95e018bbe9e7cdc7d89 Mon Sep 17 00:00:00 2001 From: kovacsbalu Date: Tue, 14 May 2019 16:06:20 +0200 Subject: [PATCH 1/2] Fix #314 Replace char on redis encoding error. Try to use local file on other error. --- bin/packages/Paste.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/packages/Paste.py b/bin/packages/Paste.py index f8be2f9b..884bd5ee 100755 --- a/bin/packages/Paste.py +++ b/bin/packages/Paste.py @@ -70,6 +70,7 @@ class Paste(object): host=cfg.get("Redis_Queues", "host"), port=cfg.getint("Redis_Queues", "port"), db=cfg.getint("Redis_Queues", "db"), + encoding_errors='replace', decode_responses=True) self.store = redis.StrictRedis( host=cfg.get("Redis_Data_Merging", "host"), @@ -125,7 +126,13 @@ class Paste(object): """ - paste = self.cache.get(self.p_path) + try: + paste = self.cache.get(self.p_path) + except Exception as e: + print("ERROR in: " + self.p_path) + print(e) + paste = None + if paste is None: try: with gzip.open(self.p_path, 'r') as f: From f61d830678b636ab777534a1fe39a51f8c54d8dd Mon Sep 17 00:00:00 2001 From: kovacsbalu Date: Thu, 16 May 2019 14:24:03 +0200 Subject: [PATCH 2/2] Use default encoding error from redis. --- bin/packages/Paste.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/packages/Paste.py b/bin/packages/Paste.py index 884bd5ee..1087880b 100755 --- a/bin/packages/Paste.py +++ b/bin/packages/Paste.py @@ -70,7 +70,6 @@ class Paste(object): host=cfg.get("Redis_Queues", "host"), port=cfg.getint("Redis_Queues", "port"), db=cfg.getint("Redis_Queues", "db"), - encoding_errors='replace', decode_responses=True) self.store = redis.StrictRedis( host=cfg.get("Redis_Data_Merging", "host"), @@ -128,6 +127,8 @@ class Paste(object): try: paste = self.cache.get(self.p_path) + except UnicodeDecodeError: + paste = None except Exception as e: print("ERROR in: " + self.p_path) print(e)