code: def snapshot(self):
          
          with self._lock:
              current_state = self.state_manager.current_state
              state_change_id = self.state_change_id
  
              # otherwise no state change was dispatched
              if state_change_id:
                  self.storage.write_state_snapshot(state_change_id, current_state)
docs: Snapshot the application state.
  
          Snapshots are used to restore the application state, either after a
          restart or a crash.