summary refs log tree commit diff
path: root/synapse/util/caches
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-06-03 11:47:07 +0100
committerErik Johnston <erik@matrix.org>2016-06-03 11:47:07 +0100
commit58a224a6515dceacebc729f1e6fbb87a22f3a35a (patch)
treedac1c9630b1bd3b77da8a64b5320bb7333f6403c /synapse/util/caches
parentSmall optimisation to CacheListDescriptor (diff)
downloadsynapse-58a224a6515dceacebc729f1e6fbb87a22f3a35a.tar.xz
Pull out update_results_dict
Diffstat (limited to 'synapse/util/caches')
-rw-r--r--synapse/util/caches/descriptors.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/synapse/util/caches/descriptors.py b/synapse/util/caches/descriptors.py
index 5be4097279..799fd2a9c6 100644
--- a/synapse/util/caches/descriptors.py
+++ b/synapse/util/caches/descriptors.py
@@ -32,7 +32,7 @@ import os
 import functools
 import inspect
 import threading
-import itertools
+
 
 logger = logging.getLogger(__name__)
 
@@ -357,17 +357,16 @@ class CacheListDescriptor(object):
                     cached_defers[arg] = res
 
             if cached_defers:
+                def update_results_dict(res):
+                    results.update(res)
+                    return results
+
                 return preserve_context_over_deferred(defer.gatherResults(
                     cached_defers.values(),
                     consumeErrors=True,
-                ).addCallback(
-                    lambda res: {
-                        k: v
-                        for k, v in itertools.chain(results.items(), res)
-                    }
-                )).addErrback(
+                ).addCallback(update_results_dict).addErrback(
                     unwrapFirstError
-                )
+                ))
             else:
                 return results