code: def set_sensor_listener(self, sensor_name, listener):
          
  
          sensor_name = resource.escape_name(sensor_name)
          sensor_obj = dict.get(self._sensor, sensor_name)
          self._sensor_listener_cache[sensor_name].append(listener)
          sensor_dict = {}
          self._logger.debug(
                  'Cached listener {} for sensor {}'
                  .format(listener, sensor_name))
          if sensor_obj:
              # The sensor exists, so register the listener and continue.
              try:
                  sensor_obj.register_listener(listener, reading=True)
                  sensor_dict[sensor_name] = listener
                  self._logger.debug(
                      'Registered listener {} for sensor {}'
                      .format(listener, sensor_name))
              except Exception as exc:
                  self._logger.exception(
                      'Unhandled exception trying to set sensor listener {} for sensor {} ({})'
                      .format(listener, sensor_name, exc))
                  sensor_dict[sensor_name] = str(exc)
          # Otherwise, depend on self._add_sensors() to handle it from the cache when the sensor appears
          raise tornado.gen.Return(sensor_dict)
docs: Set a sensor listener for a sensor even if it is not yet known
          The listener registration should persist across sensor disconnect/reconnect.
  
          sensor_name : str
              Name of the sensor
          listener : callable
              Listening callable that will be registered on the named sensor when it becomes
              available. Callable as for :meth:`KATCPSensor.register_listener`