From e55e2683cfea69409c74326422cc65b4c7327986 Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Thu, 6 Mar 2008 15:12:40 +0000 Subject: [PATCH] * psycopg/pqpath.c (_pq_fetch_tuples): Don't call Python APIs without holding the GIL. --- ChangeLog | 5 +++++ psycopg/pqpath.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index de8c2757..2bc8dc7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-03-07 James Henstridge + + * psycopg/pqpath.c (_pq_fetch_tuples): Don't call Python APIs + without holding the GIL. + 2008-02-27 James Henstridge * NEWS: add some draft NEWS items for a 2.0.7 release. diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index 27c29f71..54263bc0 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -688,12 +688,13 @@ _pq_fetch_tuples(cursorObject *curs) int fsize = PQfsize(curs->pgres, i); int fmod = PQfmod(curs->pgres, i); - PyObject *dtitem = PyTuple_New(7); - PyObject *type = PyInt_FromLong(ftype); + PyObject *dtitem; + PyObject *type; PyObject *cast = NULL; Py_BLOCK_THREADS; + dtitem = PyTuple_New(7); PyTuple_SET_ITEM(curs->description, i, dtitem); /* fill the right cast function by accessing three different dictionaries: @@ -702,6 +703,7 @@ _pq_fetch_tuples(cursorObject *curs) - the global dictionary (at module level) if we get no defined cast use the default one */ + type = PyInt_FromLong(ftype); Dprintf("_pq_fetch_tuples: looking for cast %d:", ftype); if (curs->string_types != NULL && curs->string_types != Py_None) { cast = PyDict_GetItem(curs->string_types, type);