summary refs log tree commit diff
path: root/synapse/app
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/app')
-rw-r--r--synapse/app/synchrotron.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/app/synchrotron.py b/synapse/app/synchrotron.py
index af06ce70d1..f4b416f777 100644
--- a/synapse/app/synchrotron.py
+++ b/synapse/app/synchrotron.py
@@ -163,6 +163,8 @@ class SynchrotronPresence(object):
             UPDATE_SYNCING_USERS_MS,
         )
 
+        reactor.addSystemEventTrigger("before", "shutdown", self._on_shutdown)
+
     def set_state(self, user, state):
         # TODO Hows this supposed to work?
         pass
@@ -193,6 +195,13 @@ class SynchrotronPresence(object):
 
         defer.returnValue(_user_syncing())
 
+    @defer.inlineCallbacks
+    def _on_shutdown(self):
+        # When the synchrotron is shutdown tell the master to clear the in
+        # progress syncs for this process
+        self.user_to_num_current_syncs.clear()
+        yield self._send_syncing_users_now()
+
     def _send_syncing_users_regularly(self):
         # Only send an update if we aren't in the middle of sending one.
         if not self._sending_sync: