Clear the list of ongoing syncs on shutdown

This commit is contained in:
Mark Haines 2016-06-03 15:02:27 +01:00
parent da491e75b2
commit 48340e4f13

View File

@ -163,6 +163,8 @@ class SynchrotronPresence(object):
UPDATE_SYNCING_USERS_MS, UPDATE_SYNCING_USERS_MS,
) )
reactor.addSystemEventTrigger("before", "shutdown", self._on_shutdown)
def set_state(self, user, state): def set_state(self, user, state):
# TODO Hows this supposed to work? # TODO Hows this supposed to work?
pass pass
@ -193,6 +195,13 @@ class SynchrotronPresence(object):
defer.returnValue(_user_syncing()) 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): def _send_syncing_users_regularly(self):
# Only send an update if we aren't in the middle of sending one. # Only send an update if we aren't in the middle of sending one.
if not self._sending_sync: if not self._sending_sync: