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

Commit

Permalink
Use iter* methods
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed May 22, 2018
1 parent 586b66b commit e85b5a0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def get_domains_from_state(state):
"""
joined_users = [
(state_key, int(event.depth))
for (e_type, state_key), event in state.items()
for (e_type, state_key), event in state.iteritems()
if e_type == EventTypes.Member
and event.membership == Membership.JOIN
]
Expand All @@ -780,7 +780,7 @@ def get_domains_from_state(state):
except Exception:
pass

return sorted(joined_domains.items(), key=lambda d: d[1])
return sorted(joined_domains.iteritems(), key=lambda d: d[1])

curr_domains = get_domains_from_state(curr_state)

Expand All @@ -797,7 +797,7 @@ def try_backfill(domains):
yield self.backfill(
dom, room_id,
limit=100,
extremities=[e for e in extremities.keys()]
extremities=extremities,
)
# If this succeeded then we probably already have the
# appropriate stuff.
Expand Down Expand Up @@ -843,7 +843,7 @@ def try_backfill(domains):
tried_domains = set(likely_domains)
tried_domains.add(self.server_name)

event_ids = list(extremities.keys())
event_ids = list(extremities.iterkeys())

logger.debug("calling resolve_state_groups in _maybe_backfill")
resolve = logcontext.preserve_fn(
Expand All @@ -859,15 +859,15 @@ def try_backfill(domains):
states = dict(zip(event_ids, [s.state for s in states]))

state_map = yield self.store.get_events(
[e_id for ids in states.values() for e_id in ids.itervalues()],
[e_id for ids in states.itervalues() for e_id in ids.itervalues()],
get_prev_content=False
)
states = {
key: {
k: state_map[e_id]
for k, e_id in state_dict.items()
for k, e_id in state_dict.iteritems()
if e_id in state_map
} for key, state_dict in states.items()
} for key, state_dict in states.iteritems()
}

for e_id, _ in sorted_extremeties_tuple:
Expand Down

0 comments on commit e85b5a0

Please sign in to comment.