This commit is contained in:
Patrick Cloke 2023-11-06 09:29:25 -05:00
parent 471724b9eb
commit 239630a31a
2 changed files with 20 additions and 33 deletions

View File

@ -67,12 +67,7 @@ class SynapsePlugin(Plugin):
) -> Optional[Callable[[AttributeContext], mypy.types.Type]]: ) -> Optional[Callable[[AttributeContext], mypy.types.Type]]:
# Anything in synapse could be wrapped with the cached decorator, but # Anything in synapse could be wrapped with the cached decorator, but
# we know that anything else is *not*. # we know that anything else is *not*.
if fullname.startswith( if fullname == "synapse.util.caches.descriptors.CachedFunction.__call__":
(
"synapse.util.caches.descriptors.CachedFunction",
"synapse.util.caches.descriptors._LruCachedFunction",
)
):
return cached_function_method_attribute return cached_function_method_attribute
return None return None

View File

@ -350,23 +350,16 @@ class BulkPushRuleEvaluator:
actions_by_user: Dict[str, Collection[Union[Mapping, str]]] = {} actions_by_user: Dict[str, Collection[Union[Mapping, str]]] = {}
# Gather a bunch of info in parallel. # Gather a bunch of info in parallel.
#
# This has a lot of ignored types and casting due to the use of @cached
# decorated functions passed into run_in_background.
#
# See https://github.com/matrix-org/synapse/issues/16606
( (
room_member_count, room_member_count,
(power_levels, sender_power_level), (power_levels, sender_power_level),
related_events, related_events,
profiles, profiles,
) = await make_deferred_yieldable( ) = await make_deferred_yieldable(
cast(
"Deferred[Tuple[int, Tuple[dict, Optional[int]], Dict[str, Dict[str, JsonValue]], Mapping[str, ProfileInfo]]]",
gather_results( gather_results(
( (
run_in_background( # type: ignore[call-arg] run_in_background(
self.store.get_number_joined_users_in_room, event.room_id # type: ignore[arg-type] self.store.get_number_joined_users_in_room, event.room_id
), ),
run_in_background( run_in_background(
self._get_power_levels_and_sender_level, self._get_power_levels_and_sender_level,
@ -375,15 +368,14 @@ class BulkPushRuleEvaluator:
event_id_to_event, event_id_to_event,
), ),
run_in_background(self._related_events, event), run_in_background(self._related_events, event),
run_in_background( # type: ignore[call-arg] run_in_background(
self.store.get_subset_users_in_room_with_profiles, self.store.get_subset_users_in_room_with_profiles,
event.room_id, # type: ignore[arg-type] event.room_id,
rules_by_user.keys(), # type: ignore[arg-type] rules_by_user.keys(),
), ),
), ),
consumeErrors=True, consumeErrors=True,
).addErrback(unwrapFirstError), ).addErrback(unwrapFirstError)
)
) )
# Find the event's thread ID. # Find the event's thread ID.