title: how could I publish multiple random messages for each mqtt client in a random way not sequentially to the same broker using python client?
body: <p>This is my python client code for publishing messages of 10 publishers, I want every publisher to send multiple messages not sequentially for example client 1 can publish a message then client 5 then client 1 can send again another message then client 9, and so on.</p>
  <pre><code>import paho.mqtt.client as mqtt
  import time
  import os
  import random
  
  #variables
  MQTT_HOST = &quot;127.0.0.1&quot;
  MQTT_PORT = 1883
  MQTT_KEEPALIVE_INTERVAL = 5
  MQTT_TOPIC = &quot;sampleTopic&quot;
  MQTT_MSG = &quot;Hello MQTT&quot;
  publishers = []
  num_publishers = 10
  
  
  #Callback Functions
  def on_log(client, userdata, level, buf):
      print(&quot;log: &quot;+buf)
  
  def on_connect(client, userdata, flags, rc):
      if rc == 0 :
          print(&quot;connected OK&quot;+str(client))
          mqttc.publish(MQTT_TOPIC,MQTT_MSG)
      else:
          print(&quot;Bad connection returned code = &quot;,rc)
  
  def on_disconnect(client, userdata, flags, rc=0):
      print(&quot;Disconnected result code &quot; +str(rc))
  
  def on_message(client, userdata, msg):
      topic = msg.topic
      m_decode = str(msg.payload.decode(&quot;utf-8&quot;,&quot;ignore&quot;))
      print(&quot;message received&quot;, m_decode)
         
  def on_publish(client, userdata, mid):
      print(&quot;Message Published...&quot;)
      time.sleep(random.randint(3,9))# sleep for 10 seconds before next call
      
  for i in range(num_publishers):
      #Initiate MQTT Client
      id = &quot;Publisher &quot;+str(i)
      client = mqtt.Client(id)
      publishers.append(client)
          
  try:
  
      for mqttc in publishers:
  
          #Binding Callback Functions
          mqttc.on_connect = on_connect
          mqttc.on_disconnect = on_disconnect
          mqttc.on_message = on_message
          mqttc.on_publish = on_publish
          # mqttc.on_log = on_log
  
          #connect with MQTT broker
          mqttc.connect(MQTT_HOST,MQTT_PORT,MQTT_KEEPALIVE_INTERVAL)
  
          #loop network
          mqttc.loop_start()
          time.sleep(0.5)
  
      while True:
          pass
  
  except KeyboardInterrupt:
     print(&quot;interrupted by keyboard&quot;)
  
  os._exit(0)
  
  </code></pre>
  <p>I tried paho.mqtt.publish.multiple() but it did not work for my requirements.</p>