title: Multiprocessing pool with an iterator
body: <p>I would like to use multiprocessing pool with an iterator in order to execute a function in a thread splitting the iterator in N elements until the iterator is finish.</p>
  
  <pre><code>import arcpy
  from multiprocessing import Pool
  
  def insert(rows):
      with arcpy.da.InsertCursor("c:\temp2.gdb\test" fields=["*"]) as i_cursor:
          #i_cursor is an iterator
          for row in rows:
              i_cursor.insertRow(row)
  
  input_rows = []
  count = 0
  pool = Pool(4)
  with arcpy.da.SearchCursor("c:\temp.gdb\test", fields=["*"]) as s_cursor:
      #s_cursor is an iterator
      for row in s_cursor:
          if (count &lt; 100):
              input_rows.append(row)
              count += 1
          else:
              #send 100 rows to the insert function in a new thread
              pool.apply_async(insert, input_rows)
              #reset count and input_rows
              count = 1
              input_rows = [row]
  
  
  pool.join()
  pool.close()
  </code></pre>
  
  <p>My question, is this script the right way to do it? Is there a better way?</p>
  
  <p>Probably something is wrong with that script, because I got the following AssertionError at the <code>pool.join()</code></p>
  
  <pre><code>Traceback (most recent call last):
    File "G:\Maxime\truncate_append_pool.py", line 50, in &lt;module&gt;
      pool.join()
    File "C:\App\Python27\ArcGIS10.3\lib\multiprocessing\pool.py", line 460, in join
      assert self._state in (CLOSE, TERMINATE)
  AssertionError
  </code></pre>