Re: visit_decref: Assertion `gc->gc.gc_refs != 0' failed.
Jan Urbański <[email protected]> Sat, 27 Mar 2010 03:20:07 +0100
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On 27/03/10 03:17, Jan Urbański wrote: > Here's a patch that fixes my problem. The issue seemed to be that > psycopg2 was storing the asynchronous cursor in conn->async_cursor, and Dang, previous patch had the actual reffing commented, sorry :| Correct patch attached. Jan _______________________________________________ Psycopg mailing list Psycopg-IAPFreCvJWPBWskQ1e/[email protected] http://lists.initd.org/mailman/listinfo/psycopg
0001-Ref-the-async-cursor-before-storing-it-in-the-connec.patch
(text/x-diff, 1.3 KB)
From 9e2866e52845bb88a993d92115819bb7c44f31be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Urba=C5=84ski?= <[email protected]> Date: Sat, 27 Mar 2010 03:17:22 +0100 Subject: [PATCH] Ref the async cursor before storing it in the connection --- psycopg/cursor_type.c | 1 + psycopg/pqpath.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index 4c66a06..bc7c4e9 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -1517,6 +1517,7 @@ psyco_curs_isready(cursorObject *self, PyObject *args) Py_BEGIN_ALLOW_THREADS; pthread_mutex_lock(&(self->conn->lock)); self->pgres = PQgetResult(self->conn->pgconn); + Py_XDECREF(self->conn->async_cursor); self->conn->async_cursor = NULL; pthread_mutex_unlock(&(self->conn->lock)); Py_END_ALLOW_THREADS; diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index 8b0e134..835859f 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -706,6 +706,7 @@ pq_execute(cursorObject *curs, const char *query, int async) if (pq_fetch(curs) == -1) return -1; } else { + Py_INCREF(curs); curs->conn->async_cursor = (PyObject*)curs; } -- 1.7.0