diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index a996bd7..d0a940f 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -1322,7 +1322,12 @@ _pq_copy_in_v3(cursorObject *curs) } else { /* and finally we grab the operation result from the backend */ - while ((curs->pgres = PQgetResult(curs->conn->pgconn)) != NULL) { + for (;;) { + Py_BEGIN_ALLOW_THREADS; + curs->pgres = PQgetResult(curs->conn->pgconn); + Py_END_ALLOW_THREADS; + if (!curs->pgres) + break; if (PQresultStatus(curs->pgres) == PGRES_FATAL_ERROR) pq_raise(curs->conn, curs, NULL); IFCLEARPGRES(curs->pgres);