From 66555c5f11728f25634dae70c37b02135d03b387 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 23 Feb 2011 00:48:10 +0000 Subject: [PATCH] Fixed call of memory functions without the GIL --- psycopg/pqpath.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index e0e9938e..8136d0af 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -610,6 +610,8 @@ pq_tpc_command_locked(connectionObject *conn, const char *cmd, const char *tid, conn->mark += 1; + PyEval_RestoreThread(*tstate); + /* convert the xid into the postgres transaction_id and quote it. */ if (!(etid = psycopg_escape_string((PyObject *)conn, tid, 0, NULL, NULL))) { goto exit; } @@ -623,12 +625,15 @@ pq_tpc_command_locked(connectionObject *conn, const char *cmd, const char *tid, if (0 > PyOS_snprintf(buf, buflen, "%s %s;", cmd, etid)) { goto exit; } /* run the command and let it handle the error cases */ + *tstate = PyEval_SaveThread(); rv = pq_execute_command_locked(conn, buf, pgres, error, tstate); + PyEval_RestoreThread(*tstate); exit: PyMem_Free(buf); PyMem_Free(etid); + *tstate = PyEval_SaveThread(); return rv; }