title: on_disconnect isn't being triggered python
body: <p>I've tried a number of iterations of this code.  This is the last attempt and I'm stumped.  It never sees the published message in addition to not getting the on disconnect.</p>
  
  <pre><code>#!/usr/bin/python3
  import paho.mqtt.client as mqtt  #import the client1
  import time
  
  def on_message(client, userdata, message):
    print("received message =",str(message.payload.decode("utf-8")))
  
  def on_disconnect(client, userdata, flags, rc):
      client.connected_flag=False #set flag
      print("disconnected OK")
  
  def on_connect(client, userdata, flags, rc):
      if rc==0:
          client.connected_flag=True #set flag
          print("connected OK")
          client.subscribe("Phone/announcet")#subscribe
          print("subscribed OK")
      else:
          print("Bad connection Returned code=",rc)
  
  mqtt.Client.connected_flag=False#create flag in class
  broker="192.168.1.71"
  client = mqtt.Client()             #create new instance 
  print("Connecting to broker ",broker)
  client.username_pw_set(username="zzz",password="xxx")
  while True:
      client.on_connect=on_connect  #bind call back function
      client.on_disconnect=on_disconnect
      client.connect(broker)      #connect to broker
      client.loop_start()
      while not client.connected_flag: #wait in loop
          print("In wait loop")
          time.sleep(1)
      print("in Main Loop")
      time.sleep(2)
      client.loop_stop()    #Stop loop 
      client.disconnect() # disconnect
      print("After disconnect")
  </code></pre>
  
  <p>Here is what the output looks like:</p>
  
  <pre><code>Connecting to broker  192.168.1.71
  In wait loop
  connected OK
  subscribed OK
  in Main Loop
  After disconnect
  in Main Loop
  connected OK
  subscribed OK
  After disconnect
  in Main Loop
  connected OK
  subscribed OK
  After disconnect
  </code></pre>
  
  <p>Thanks,
  Jim</p>