Ref the async cursor before storing it in the connection

This commit is contained in:
Jan Urbański 2010-03-27 03:21:47 +01:00 committed by Federico Di Gregorio
parent eb646f71fa
commit 062a9602ae
2 changed files with 3 additions and 0 deletions

View File

@ -74,6 +74,7 @@ curs_get_last_result(cursorObject *self) {
IFCLEARPGRES(self->pgres);
self->pgres = pgres;
}
Py_XDECREF(self->conn->async_cursor);
self->conn->async_cursor = NULL;
pthread_mutex_unlock(&(self->conn->lock));
Py_END_ALLOW_THREADS;

View File

@ -299,6 +299,7 @@ pq_clear_async(connectionObject *conn)
Dprintf("pq_clear_async: clearing PGresult at %p", pgres);
CLEARPGRES(pgres);
}
Py_XDECREF(conn->async_cursor);
conn->async_cursor = NULL;
}
@ -746,6 +747,7 @@ pq_execute(cursorObject *curs, const char *query, int async)
}
else {
curs->conn->async_status = async_status;
Py_INCREF(curs);
curs->conn->async_cursor = (PyObject*)curs;
}