title: Psycopg2 concurrency issue
body: <p>I am trying to do share a psycopg2 connection between multiple threads. As was mentioned in the docs, I am doing that by creating new cursor objects from the shared connection, whenever I use it in a new thread.</p>
  
  <pre><code>def delete(conn):
      while True:
          conn.commit()
  
  def test(conn):    
      cur = conn.cursor()
      thread.start_new_thread(delete,(conn,))
      i = 1
      while True:
          cur.execute("INSERT INTO mas(taru,s) values (2,%s)",(i,))
          print i
          i = i +1
          conn.commit()
  </code></pre>
  
  <p>After running, I get output like, </p>
  
  <pre><code>1
  2
  ...
  98  
  99
  Traceback (most recent call last):
  File "postgres_test_send.py", line 44, in &lt;module&gt;
     cur.execute("INSERT INTO mas(taru,s) values (2,%s)",(i,))
  psycopg2.InternalError: SET TRANSACTION ISOLATION LEVEL must be called before any query
  </code></pre>
  
  <p>What's going on here?</p>