'We periodically persist the unpersisted changes, as otherwise they
may stack up and slow down shutdown times.'

@defer.inlineCallbacks
def _persist_unpersisted_changes(self):

    logger.info('Performing    _persist_unpersisted_changes.    Persisting    %d    unpersisted    changes', len(self.unpersisted_users_changes))
    unpersisted = self.unpersisted_users_changes
    self.unpersisted_users_changes = set()
    if unpersisted:
        (yield self.store.update_presence([self.user_to_current_state[user_id] for user_id in unpersisted]))
    logger.info('Finished    _persist_unpersisted_changes')
