1515import abc
1616import logging
1717from collections import OrderedDict
18- from typing import TYPE_CHECKING , Dict , Hashable , Iterable , List , Optional , Set , Tuple
18+ from typing import (
19+ TYPE_CHECKING ,
20+ Collection ,
21+ Dict ,
22+ Hashable ,
23+ Iterable ,
24+ List ,
25+ Optional ,
26+ Set ,
27+ Tuple ,
28+ )
1929
2030import attr
2131from prometheus_client import Counter
@@ -409,7 +419,7 @@ async def handle_event(event: EventBase) -> None:
409419 )
410420 return
411421
412- destinations : Optional [Set [str ]] = None
422+ destinations : Optional [Collection [str ]] = None
413423 if not event .prev_event_ids ():
414424 # If there are no prev event IDs then the state is empty
415425 # and so no remote servers in the room
@@ -444,7 +454,7 @@ async def handle_event(event: EventBase) -> None:
444454 )
445455 return
446456
447- destinations = {
457+ sharded_destinations = {
448458 d
449459 for d in destinations
450460 if self ._federation_shard_config .should_handle (
@@ -456,12 +466,12 @@ async def handle_event(event: EventBase) -> None:
456466 # If we are sending the event on behalf of another server
457467 # then it already has the event and there is no reason to
458468 # send the event to it.
459- destinations .discard (send_on_behalf_of )
469+ sharded_destinations .discard (send_on_behalf_of )
460470
461- logger .debug ("Sending %s to %r" , event , destinations )
471+ logger .debug ("Sending %s to %r" , event , sharded_destinations )
462472
463- if destinations :
464- await self ._send_pdu (event , destinations )
473+ if sharded_destinations :
474+ await self ._send_pdu (event , sharded_destinations )
465475
466476 now = self .clock .time_msec ()
467477 ts = await self .store .get_received_ts (event .event_id )
0 commit comments