From e8286084e9400ae634f06e9da34e4de474b51eb7 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 7 Apr 2010 23:52:53 +0100 Subject: [PATCH] Free the GIL in blocking operations in V2 COPY FROM. --- psycopg/pqpath.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index 71628301..ee132ab6 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -1065,13 +1065,18 @@ _pq_copy_in(cursorObject *curs) o = PyObject_CallFunction(func, NULL); if (o == NULL) goto clear; if (o == Py_None || PyString_GET_SIZE(o) == 0) break; + Py_BEGIN_ALLOW_THREADS; rv = PQputline(curs->conn->pgconn, PyString_AS_STRING(o)); + Py_END_ALLOW_THREADS; Py_DECREF(o); if (0 != rv) goto clear; } Py_XDECREF(o); + + Py_BEGIN_ALLOW_THREADS; PQputline(curs->conn->pgconn, "\\.\n"); PQendcopy(curs->conn->pgconn); + Py_END_ALLOW_THREADS; /* if for some reason we're using a protocol 3 libpq to connect to a protocol 2 backend we still need to cycle on the result set */