Update Redis exception to drop stack trace

Full stack trace is probably not needed as the Redis data corruption is probably happening somewhere else, the error log should make it easier to investigate it when it does happen.
This commit is contained in:
Ken Tsang 2019-05-08 11:26:05 +01:00
parent edcf80c944
commit 0cbb3579a9
2 changed files with 4 additions and 6 deletions

View File

@ -212,11 +212,9 @@ class RedisConsumer(object):
while True:
key, body = self.redis.blpop(self.routing_key)
try:
self.redis.set(self.persistance_key(body),
str(datetime.datetime.now()))
except Exception:
import traceback
log.error("Redis Exception: %s %s", traceback.format_stack(), traceback.format_exc())
self.redis.set(self.persistance_key(body), str(datetime.datetime.now()))
except Exception as e:
log.error("Redis Exception: %s", e)
continue
yield (FakeMethod(body), self, body)

View File

@ -344,7 +344,7 @@ class TestHarvestCorruptRedis(object):
assert mock_log_error.call_count == 1
args, _ = mock_log_error.call_args_list[0]
assert "TypeError: cannot concatenate 'str' and 'NoneType' objects" in args[2]
assert "cannot concatenate 'str' and 'NoneType' objects" in args[1]
finally:
redis.delete('ckanext-harvest:some-random-key-2')