Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Consistently return a Deferred in the descriptor cache #3455

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added changelog.d/3455.misc
Empty file.
2 changes: 1 addition & 1 deletion synapse/push/bulk_push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _get_rules_for_event(self, event, context):
dict of user_id -> push_rules
"""
room_id = event.room_id
rules_for_room = self._get_rules_for_room(room_id)
rules_for_room = yield self._get_rules_for_room(room_id)

rules_by_user = yield rules_for_room.get_rules(event, context)

Expand Down
5 changes: 4 additions & 1 deletion synapse/util/caches/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ def invalidate_all(self):
class _CacheDescriptorBase(object):
def __init__(self, orig, num_args, inlineCallbacks, cache_context=False):
self.orig = orig
self.inlineCallbacks = inlineCallbacks

if inlineCallbacks:
if self.inlineCallbacks:
self.function_to_call = defer.inlineCallbacks(orig)
else:
self.function_to_call = orig
Expand Down Expand Up @@ -380,6 +381,8 @@ def wrapped(*args, **kwargs):

if isinstance(cached_result_d, ObservableDeferred):
observer = cached_result_d.observe()
elif self.inlineCallbacks:
observer = defer.succeed(cached_result_d)
else:
observer = cached_result_d

Expand Down