title: Communication of errors between threads?
body: <p>I have a question ID someone can help me please, I have a list of IP addresses and in each time a use one address to send some requests using python threads.
  the problem is I don't know how I can switch between the IPs when any exception is raised.</p>
  <p>For example, I have 5 threads and the exception is raised first in thread 4, so it will change the IP address by incrementing the iteration index the problem is when the other threads will face the same the exception they will not use the same address as thread 4.</p>
  <pre><code>def fct(elm,IP):
     do work
     if ip is not valid:
     raise invalid_IP
  
  jobs = Queue()
  
  
  def do_stuff(q,Ip_adress):
      while not q.empty():
          try:
              value = q.get()
              fct(item=value,IP)
              q.task_done()
          except invalid_IP:
              #move to the next IP and retry
  
  
  for i in lines:
      jobs.put(i)
  Ip_adress = [IP1,IP2]
  for i in range(5):
      worker = threading.Thread(target=do_stuff, args=(jobs,Ip_adress))
      worker.start()
  
  jobs.join()
  </code></pre>