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

Commit

Permalink
Remove redundant PreserveLoggingContext
Browse files Browse the repository at this point in the history
Both (!) things that register as replication listeners do the right thing wrt
logcontexts, so this is redundant.
  • Loading branch information
richvdh committed Mar 4, 2019
1 parent daa10e3 commit c732577
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions synapse/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ def count_listeners():

def add_replication_callback(self, cb):
"""Add a callback that will be called when some new data is available.
Callback is not given any arguments.
Callback is not given any arguments. It should *not* return a Deferred - if
it needs to do any asynchronous work, a background thread should be started and
wrapped with run_as_background_process.
"""
self.replication_callbacks.append(cb)

Expand Down Expand Up @@ -515,12 +517,5 @@ def _user_joined_room(self, user_id, room_id):

def notify_replication(self):
"""Notify the any replication listeners that there's a new event"""
with PreserveLoggingContext():
# the callbacks may well outlast the current request, so we run
# them in the sentinel logcontext.
#
# (ideally it would be up to the callbacks to know if they were
# starting off background processes and drop the logcontext
# accordingly, but that requires more changes)
for cb in self.replication_callbacks:
cb()
for cb in self.replication_callbacks:
cb()

0 comments on commit c732577

Please sign in to comment.