mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-16 06:51:46 +01:00
Pull out update_results_dict
This commit is contained in:
parent
e043ede4a2
commit
58a224a651
1 changed files with 7 additions and 8 deletions
|
@ -32,7 +32,7 @@ import os
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import threading
|
import threading
|
||||||
import itertools
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -357,17 +357,16 @@ class CacheListDescriptor(object):
|
||||||
cached_defers[arg] = res
|
cached_defers[arg] = res
|
||||||
|
|
||||||
if cached_defers:
|
if cached_defers:
|
||||||
|
def update_results_dict(res):
|
||||||
|
results.update(res)
|
||||||
|
return results
|
||||||
|
|
||||||
return preserve_context_over_deferred(defer.gatherResults(
|
return preserve_context_over_deferred(defer.gatherResults(
|
||||||
cached_defers.values(),
|
cached_defers.values(),
|
||||||
consumeErrors=True,
|
consumeErrors=True,
|
||||||
).addCallback(
|
).addCallback(update_results_dict).addErrback(
|
||||||
lambda res: {
|
|
||||||
k: v
|
|
||||||
for k, v in itertools.chain(results.items(), res)
|
|
||||||
}
|
|
||||||
)).addErrback(
|
|
||||||
unwrapFirstError
|
unwrapFirstError
|
||||||
)
|
))
|
||||||
else:
|
else:
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue