mirror of
https://github.com/element-hq/synapse
synced 2024-08-21 09:00:21 +00:00
make FederationHandler._handle_new_events async
This commit is contained in:
parent
6e89ec5e32
commit
c556ed9e15
1 changed files with 6 additions and 8 deletions
|
@ -1815,13 +1815,12 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
async def _handle_new_events(
|
||||||
def _handle_new_events(
|
|
||||||
self,
|
self,
|
||||||
origin: str,
|
origin: str,
|
||||||
event_infos: Iterable[_NewEventInfo],
|
event_infos: Iterable[_NewEventInfo],
|
||||||
backfilled: bool = False,
|
backfilled: bool = False,
|
||||||
):
|
) -> None:
|
||||||
"""Creates the appropriate contexts and persists events. The events
|
"""Creates the appropriate contexts and persists events. The events
|
||||||
should not depend on one another, e.g. this should be used to persist
|
should not depend on one another, e.g. this should be used to persist
|
||||||
a bunch of outliers, but not a chunk of individual events that depend
|
a bunch of outliers, but not a chunk of individual events that depend
|
||||||
|
@ -1830,11 +1829,10 @@ class FederationHandler(BaseHandler):
|
||||||
Notifies about the events where appropriate.
|
Notifies about the events where appropriate.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
async def prep(ev_info: _NewEventInfo):
|
||||||
def prep(ev_info: _NewEventInfo):
|
|
||||||
event = ev_info.event
|
event = ev_info.event
|
||||||
with nested_logging_context(suffix=event.event_id):
|
with nested_logging_context(suffix=event.event_id):
|
||||||
res = yield self._prep_event(
|
res = await self._prep_event(
|
||||||
origin,
|
origin,
|
||||||
event,
|
event,
|
||||||
state=ev_info.state,
|
state=ev_info.state,
|
||||||
|
@ -1843,14 +1841,14 @@ class FederationHandler(BaseHandler):
|
||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
contexts = yield make_deferred_yieldable(
|
contexts = await make_deferred_yieldable(
|
||||||
defer.gatherResults(
|
defer.gatherResults(
|
||||||
[run_in_background(prep, ev_info) for ev_info in event_infos],
|
[run_in_background(prep, ev_info) for ev_info in event_infos],
|
||||||
consumeErrors=True,
|
consumeErrors=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
yield self.persist_events_and_notify(
|
await self.persist_events_and_notify(
|
||||||
[
|
[
|
||||||
(ev_info.event, context)
|
(ev_info.event, context)
|
||||||
for ev_info, context in zip(event_infos, contexts)
|
for ev_info, context in zip(event_infos, contexts)
|
||||||
|
|
Loading…
Reference in a new issue