summary refs log tree commit diff
path: root/synapse/util/caches/deferred_cache.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2020-10-21 18:54:53 +0100
committerRichard van der Hoff <richard@matrix.org>2020-10-21 18:54:53 +0100
commitc13820bcee5f23119b65f9386b7c03bd4a33acbe (patch)
tree23f500efd69e4d39ca593ebc9c13560f1a155df4 /synapse/util/caches/deferred_cache.py
parentoptimise DeferredCache.set (diff)
downloadsynapse-c13820bcee5f23119b65f9386b7c03bd4a33acbe.tar.xz
fix failure case
Diffstat (limited to 'synapse/util/caches/deferred_cache.py')
-rw-r--r--synapse/util/caches/deferred_cache.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/synapse/util/caches/deferred_cache.py b/synapse/util/caches/deferred_cache.py
index fc01026285..601305487c 100644
--- a/synapse/util/caches/deferred_cache.py
+++ b/synapse/util/caches/deferred_cache.py
@@ -31,6 +31,7 @@ from typing import (
 from prometheus_client import Gauge
 
 from twisted.internet import defer
+from twisted.python import failure
 
 from synapse.util.async_helpers import ObservableDeferred
 from synapse.util.caches.lrucache import LruCache
@@ -223,7 +224,9 @@ class DeferredCache(Generic[KT, VT]):
 
         # we can save a whole load of effort if the deferred is ready.
         if value.called:
-            self.cache.set(key, value.result, callbacks)
+            result = value.result
+            if not isinstance(result, failure.Failure):
+                self.cache.set(key, result, callbacks)
             return value
 
         # otherwise, we'll add an entry to the _pending_deferred_cache for now,