code: def state_change_handler(self, evt):
          
          datapath = evt.datapath
          assert datapath is not None
          if datapath.id == self._querier.dpid:
              if evt.state == MAIN_DISPATCHER:
                  self._querier.start_loop(datapath)
              elif evt.state == DEAD_DISPATCHER:
                  self._querier.stop_loop()
docs: StateChange event handler.