title: Pool.map function in multiprocessing issue
body: <p>I have an issue with the &quot;pool.map&quot; function in my code. The significant part of my code is as following:</p>
  <pre><code>import multiprocessing as mp
  pool = mp.Pool(4)
  list_of_as = range(200)
  
  def run_test(a):    
      df = classA.method1(a)
      condition = classA.method2(a)
      if condition:
          in_position = classA.method3(a)
          
  def run():
      p = tuple(pool.map(run_test, list_of_as))
      return p
  
  if __name__ == &quot;__main__&quot;:
      start = time.time()
      #schedule.every(1).seconds.do(run)
      run()
      end = time.time()
      print(f&quot;Execution time of the loop: {(end-start)/60} minutes&quot;)
  </code></pre>
  <p>I call some methods of a given class that i have in another file, then, <strong>to speed up my  code</strong>, i do multiprocessing in a separate function. In the <code>run_test</code> function that i call in <code>run</code>, i use pandas dataframes plus some very heavy computation and api calls.
  When <code>condition == True</code>, <code>classA.method3(a)</code> function is executed and <code>in_position</code> becomes <code>True</code>. At this stage, when <code>condition</code> is satisfied, <strong>I want to pause all the other processes and keep going with only the one that satisfied the condition until <code>in_position</code> becomes <code>False</code></strong>.</p>
  <p>My <strong>second issue is the following error that i have when i run the code</strong>:</p>
  <pre><code>  File &quot;/home/lib/python3.9/multiprocessing/queues.py&quot;, line 368, in get
      return _ForkingPickler.loads(res)
  AttributeError: Can't get attribute 'run_test' on &lt;module '__main__' from '/home/md/miniconda3/git/simulate/sim_4/run.py'&gt;
  </code></pre>
  <ul>
  <li>The second issue is optional because it seems that it doesn't really block the code from running, however solving the first issue is very important to me!</li>
  </ul>
  <p>P.S. (The complete version of the program runs with scheduling)</p>
  <p>Thank you very much for your help !</p>