code: def publish(self, topic, payload, qos=0, retain=False, wait=False):
          
          result = self.__mqtt.publish(topic, payload, qos, retain)
          if wait and not result[0]:
              # Publish packet sent, wait for it to return
              self.__in_flight[result[1]] = threading.Event()
              _logger.debug("Waiting for publication of %s", topic)
  
          return result[1]
docs: Sends a message through the MQTT connection
  
          :param topic: Message topic
          :param payload: Message content
          :param qos: Quality of Service
          :param retain: Retain flag
          :param wait: If True, prepares an event to wait for the message to be
                       published
          :return: The local message ID, None on error