title: Multiprocess over python with psycopg2
body: <p>I'm working on python to add many records into a Postgres DB, because I have to insert millions records I need to parallelize 2 functions:</p>
  
  <pre><code>insert_A(cur)  
  insert_B(cur) 
  </code></pre>
  
  <p>where:</p>
  
  <pre><code>conn=psycopg2.connect(.....)
  cur = conn.cursor() 
  </code></pre>
  
  <p>I tried a solution I found in another post here in stack overflow like:  </p>
  
  <pre><code>result1= pool.apply_async(insert_A, cur)  
  result2= pool.apply_async(insert_B, cur)  
  answer1=result1.get(timeout=15)  
  answer2=result2.get(timeout=15)  
  </code></pre>
  
  <p>but I got this error:
  Traceback (most recent call last):<br>
    File "test.py", line 387, in <br>
      answer1=result1.get(timeout=15)<br>
    File     "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 558, in get<br>
      raise self._value<br>
  psycopg2.InterfaceError: the cursor has no connection  </p>
  
  <p>somebody could help me please? :(</p>