title: Python error: execute cannot be used while an asynchronous query is underway
body: <p>How do I prevent the error “<code>ProgrammingError: execute cannot be used while an asynchronous query is underway</code>”? From the docs it says that I should use psycopg2.extras.wait_select if I’m using a coroutine support like gevent., but I’m still get that error when I’m using it. I’ve isolated the error I’m getting in the snippet below.</p>
  
  <pre><code>con = psycopg2.connect(database=DATABASE_NAME, user=DATABASE_USERNAME)
  
  def execute_query(cur, query, params):
      psycopg2.extras.wait_select(con)
      cur.execute(query, params)
      psycopg2.extras.wait_select(con)
      rows = cur.fetchall()
      print rows[0]
  
  cur = con.cursor()
  query = "SELECT * FROM mytable"
  gevent.joinall([
       gevent.spawn(execute_query, cur, query, None),
       gevent.spawn(execute_query, cur, query, None),
       gevent.spawn(execute_query, cur, query, None),
       gevent.spawn(execute_query, cur, query, None)
  ])
  </code></pre>