def _global_watch(self, zh, event, state, path):
    logging.debug('Global watch fired: %s %s %s' % (event, state, path))
    if state == zookeeper.EXPIRED_SESSION_STATE:
      self._clientid = None
      self._connect()
    elif state == zookeeper.CONNECTED_STATE:
      # Re-get all existing watched files.
      if self._clientid is not None:
        logging.debug('Session reconnection.')
      else:
        self._clientid = zookeeper.client_id(self._zookeeper)
        logging.debug('Registering watches to reestablish expired session')
        for path in self._watches.iterkeys():
          logging.debug('Registering watch against: %s' % path)
          h = self._handler_wrapper(path)
          zookeeper.aget(self._zookeeper, path, self._watcher, h)

        # Catch up all gets requested before we were able to connect.
        while self._pending_gets:
          path, w, h = self._pending_gets.pop()
          zookeeper.aget(self._zookeeper, path, w, h)
Called when the connection to zookeeper has a state change.
dataset/ETHPy150Open liquidgecka/twitcher/twitcher/zkwrapper.py/ZKWrapper._global_watch