code: def publish(self, topic, message, qos=None, retain=None, ack_timeout=None):
          
  
          def get_retain_and_qos():
              if qos:
                  assert qos in (QOS_0, QOS_1, QOS_2)
                  _qos = qos
              else:
                  _qos = self.config['default_qos']
                  try:
                      _qos = self.config['topics'][topic]['qos']
                  except KeyError:
                      pass
              if retain:
                  _retain = retain
              else:
                  _retain = self.config['default_retain']
                  try:
                      _retain = self.config['topics'][topic]['retain']
                  except KeyError:
                      pass
              return _qos, _retain
          (app_qos, app_retain) = get_retain_and_qos()
          return (yield from self._handler.mqtt_publish(topic, message, app_qos, app_retain, ack_timeout))
docs: Publish a message to the broker.
  
              Send a MQTT `PUBLISH <http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718037>`_ message and wait for acknowledgment depending on Quality Of Service
  
              This method is a *coroutine*.
  
              :param topic: topic name to which message data is published
              :param message: payload message (as bytes) to send.
              :param qos: requested publish quality of service : QOS_0, QOS_1 or QOS_2. Defaults to ``default_qos`` config parameter or QOS_0.
              :param retain: retain flag. Defaults to ``default_retain`` config parameter or False.