title: Python paho MQTT, client.on_publish not called even though message is sent to broker
body: <p>Ok so this is one of those &quot;what-am-I-missing-here?&quot; kind of questions.</p>
  <p>My callback registered for the client.on_publish event is never called even though messages are successfully published to the broker (no log messages are printed from the callback and it doesn't stop on a break point in VS Code). The message in particular that I'm interested in is published from the on_msg callback, I have tried to publish it outside of any callbacks but it makes no difference, the message is received by the broker but the on_publish callback never triggers.</p>
  <p>When debugging I can see that at the time of publishing there is a function registered for the on_publish callback (the client._on_publish property is set)</p>
  <p>Python version 3.7.4</p>
  <p>OS Windows 10</p>
  <p>Code that initializes the client:</p>
  <pre><code>import paho.mqtt.client as mqtt
  
  #configure mqtt client
  client = mqtt.Client(config['MQTT']['client_id'])
  client.on_connect = on_connect
  client.on_message = on_msg
  client.on_disconnect = on_disconnect
  client.on_publish = on_publish
  
  try:
      client.connect(config[&quot;MQTT&quot;][&quot;host&quot;], int(config[&quot;MQTT&quot;][&quot;port&quot;]))
  except Exception as e:
      log.error(&quot;Failed to connect to MQTT broker&quot;, exc_info=True)
  
  client.loop_start()
  </code></pre>
  <p>My callbacks for on_msg and on_publish:</p>
  <pre><code>def on_msg(client, userdata, msg):
      global status_msg_id
  
      log.debug(&quot;on_msg&quot;)
      payload = json.loads(msg.payload)
      if payload['id'] == config[&quot;MISC&quot;][&quot;session_id&quot;]:
          if payload['result'] == 0:
              log.debug(&quot;payload content=ok&quot;)
              status_msg_id = client.publish(
                  topic = config[&quot;MQTT&quot;][&quot;pub_status&quot;],
                  payload = json.dumps({'status':'ok'}),
                  qos = 2)
          else:
              log.debug(&quot;payload content=error&quot;)
              client.publish(
                  topic = config[&quot;MQTT&quot;][&quot;pub_status&quot;],
                  payload = json.dumps({'status':'error'}),
                  qos = 2)
          log.debug(&quot;msg id (mid) of status msg: {}&quot;.format(status_msg_id))
  
  def on_publish(client, userdata, mid, granted_qos):
      log.debug(&quot;on_publish, mid {}&quot;.format(mid))
      # we never get here :(
  </code></pre>
  <p>So, why isn't the on_publish function called, what am I missing?</p>