summary refs log tree commit diff
path: root/synapse/replication/tcp/resource.py
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2018-07-25 11:54:33 +0100
committerGitHub <noreply@github.com>2018-07-25 11:54:33 +0100
commit1bfb5bed1d50f8e02e0baad63b94708ece78dacc (patch)
tree9624d14b6622584e27f9bd3ae84dfaf4dd8b7ab2 /synapse/replication/tcp/resource.py
parentMerge pull request #3597 from matrix-org/erikj/did_forget (diff)
parentFix unit tests (diff)
downloadsynapse-1bfb5bed1d50f8e02e0baad63b94708ece78dacc.tar.xz
Merge pull request #3604 from matrix-org/rav/background_process_fixes
Wrap a number of things that run in the background
Diffstat (limited to 'synapse/replication/tcp/resource.py')
-rw-r--r--synapse/replication/tcp/resource.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/synapse/replication/tcp/resource.py b/synapse/replication/tcp/resource.py

index 611fb66e1d..fd59f1595f 100644 --- a/synapse/replication/tcp/resource.py +++ b/synapse/replication/tcp/resource.py
@@ -25,6 +25,7 @@ from twisted.internet import defer from twisted.internet.protocol import Factory from synapse.metrics import LaterGauge +from synapse.metrics.background_process_metrics import run_as_background_process from synapse.util.metrics import Measure, measure_func from .protocol import ServerReplicationStreamProtocol @@ -117,7 +118,6 @@ class ReplicationStreamer(object): for conn in self.connections: conn.send_error("server shutting down") - @defer.inlineCallbacks def on_notifier_poke(self): """Checks if there is actually any new data and sends it to the connections if there are. @@ -132,14 +132,16 @@ class ReplicationStreamer(object): stream.discard_updates_and_advance() return - # If we're in the process of checking for new updates, mark that fact - # and return + self.pending_updates = True + if self.is_looping: - logger.debug("Noitifier poke loop already running") - self.pending_updates = True + logger.debug("Notifier poke loop already running") return - self.pending_updates = True + run_as_background_process("replication_notifier", self._run_notifier_loop) + + @defer.inlineCallbacks + def _run_notifier_loop(self): self.is_looping = True try: