title: Execute many threads and gather results in Python?
body: <p>Working on project in Python, and unfortunately i am newbie in Python.
  The code must execute multiple probes simultaneously and gather the results.</p>
  <p>I created the following code to run the probes in different threads and gather the results (used one of the answers here : <a href="https://stackoverflow.com/questions/6893968/how-to-get-the-return-value-from-a-thread-in-python">How to get the return value from a thread in python?</a>)</p>
  <pre><code>        summary = ProbeRunnerResult()
          jobs = []
          queues = []
  
          for probe in self.probes.values():
                  que = Queue()
                  t = threading.Thread(target=lambda q, arg1: q.put(probe.run_check(arg1)), args=(que, context))
                  jobs.append(t)
                  queues.append(que)
                 
          for j in jobs:
              j.start()
  
          for j in jobs:
              j.join()
  
          for next_queue in queues:
              summary.probe_results.append(next_queue.get())
  
  
  </code></pre>
  <p>and the code of ProbeRunnerResult is :</p>
  <pre><code>class ProbeRunnerResult:
      &quot;&quot;&quot;Probe runner result. Includes results from multiple probes&quot;&quot;&quot;
      def __init__(self) -&gt; None:
          self.start_time = time.time()
          self.end_time = 0
          self.probe_results: List[ProbeResult] = []
  </code></pre>
  <p>The probe.run_check() returns an object of type/class ProbeResult.
  I face two problems:
  1.I put break points and dumps in the run_check() method of the Probe class, but they show, that the run_check() method of only the first listed probe is called multiple times.
  2.Some of the probes execution (the execution of the run_check() method) can take minutes and i am not sure whether the current code is actually handling this correctly.</p>
  <p>So i need advices how to handle these two problems correctly.</p>