title: How to run multiple publishers at the same time paho-mqtt?
body: <p>I am running a single script with several clients publishing to the same topic, 5 messages each, but they do it one after another. I would like to know if there is any way to execute several publishers but at the same time and not for a loop &quot;for &quot;as I programmed it.</p>
  <p>It occurred to me to run various python scripts but it is not functional if I want to have for example 100 publishers. Anyone have an idea how I could do it? Thanks in advance</p>
  <pre><code>import ssl
  import time 
  import random
  import sys  
  import paho.mqtt.publish as publish
  import paho.mqtt.client as mqtt
  from datetime import datetime
  
  broker_address = '127.0.0.1'
  topic = &quot;casa/hab1&quot;
  port=1883
  delay=0.2
  count=0
  i=0
  j=0
  nclients=1
  nmessages=5
  
  
  for i in range(nclients):
    cname=&quot;Client&quot;+str(i) 
    j=int(time.time()) #eliminar la parte decimal
    j=str(j)
    client_id=cname+str(j)+&quot;_&quot; #generar client_id
    client=mqtt.Client(client_id) 
    client.connect(broker_address)  
    print(&quot;&quot;)
  
    print(str(client_id))
    client.loop_start() 
  
    for count in range(nmessages):
       b=random.randrange(10, 99, 1)
       mensaje=&quot;Hello World:&quot;+ str(b)+&quot; -- &quot;
       client.publish(topic,mensaje, 2, retain=False) 
       now=datetime.now().strftime(&quot;%Y-%m-%d %H:%M:%S.%f&quot;)
       print(&quot;timestamp &quot;+str(count)+&quot; = &quot;+now)
       
       count+=1
       time.sleep(delay)
  
    i+=1
  </code></pre>