title: How to multiprocess a function in python
body: <p>My codes:</p>
  <pre><code>for batchList in all_List:
      result = getBatch_filter(batchList, entTotal, tripleList, neg_rate)
  
  def getBatch_filter(batchList, entTotal, tripleList, neg_rate):
      result = []
      for item in batchList:
          a = corrupt_a(item, entTotal, tripleList, neg_rate)
          b = corrupt_b(item, entTotal, tripleList, neg_rate)
          result += a
          result += b
      return result
  </code></pre>
  <p>where batchList, a, b are nested lists like: <code>[[1,2,3],[3,4,1,4,6],[6,9,10,11]...]</code>
  I would like to multiprocess the <code>for</code> loop in the function <code>getBatch_filter</code>. I have tried Pool, but it runs the entire file instead of the function. Any help would be appreciated.</p>