Poke notifier on next reactor tick

erikj/timings
Erik Johnston 2016-06-02 13:02:33 +01:00
parent 98fdc155c8
commit 6de4d824e3
1 changed files with 11 additions and 8 deletions

View File

@ -26,9 +26,9 @@ from synapse.types import (
UserID, RoomAlias, RoomStreamToken, StreamToken, get_domain_from_id UserID, RoomAlias, RoomStreamToken, StreamToken, get_domain_from_id
) )
from synapse.util import unwrapFirstError from synapse.util import unwrapFirstError
from synapse.util.async import concurrently_execute from synapse.util.async import concurrently_execute, run_on_reactor
from synapse.util.caches.snapshot_cache import SnapshotCache from synapse.util.caches.snapshot_cache import SnapshotCache
from synapse.util.logcontext import PreserveLoggingContext, preserve_fn from synapse.util.logcontext import preserve_fn
from synapse.util.logutils import log_duration from synapse.util.logutils import log_duration
from synapse.visibility import filter_events_for_client from synapse.visibility import filter_events_for_client
@ -913,14 +913,17 @@ class MessageHandler(BaseHandler):
"Failed to get destination from event %s", s.event_id "Failed to get destination from event %s", s.event_id
) )
with log_duration("on_new_room_event"): @defer.inlineCallbacks
with PreserveLoggingContext(): def _notify():
# Don't block waiting on waking up all the listeners. yield run_on_reactor()
self.notifier.on_new_room_event( self.notifier.on_new_room_event(
event, event_stream_id, max_stream_id, event, event_stream_id, max_stream_id,
extra_users=extra_users extra_users=extra_users
) )
with log_duration("on_new_room_event"):
preserve_fn(_notify)()
# If invite, remove room_state from unsigned before sending. # If invite, remove room_state from unsigned before sending.
event.unsigned.pop("invite_room_state", None) event.unsigned.pop("invite_room_state", None)