mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-01 01:44:07 +03:00
Use direct call to consume() callable in pq_copy_both()
This commit is contained in:
parent
22cbfb26d6
commit
76c7f4a0b5
|
@ -1737,12 +1737,11 @@ pq_copy_both(replicationCursorObject *repl, PyObject *consume, int decode,
|
||||||
connectionObject *conn = curs->conn;
|
connectionObject *conn = curs->conn;
|
||||||
PGconn *pgconn = conn->pgconn;
|
PGconn *pgconn = conn->pgconn;
|
||||||
PyObject *msg, *tmp = NULL;
|
PyObject *msg, *tmp = NULL;
|
||||||
PyObject *consume_func = NULL;
|
|
||||||
int fd, sel, ret = -1;
|
int fd, sel, ret = -1;
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
struct timeval keep_intr, curr_time, ping_time, timeout;
|
struct timeval keep_intr, curr_time, ping_time, timeout;
|
||||||
|
|
||||||
if (!(consume_func = PyObject_GetAttrString(consume, "__call__"))) {
|
if (!PyCallable_Check(consume)) {
|
||||||
Dprintf("pq_copy_both: expected callable consume object");
|
Dprintf("pq_copy_both: expected callable consume object");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1804,11 +1803,11 @@ pq_copy_both(replicationCursorObject *repl, PyObject *consume, int decode,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tmp = PyObject_CallFunctionObjArgs(consume_func, msg, NULL);
|
tmp = PyObject_CallFunctionObjArgs(consume, msg, NULL);
|
||||||
Py_DECREF(msg);
|
Py_DECREF(msg);
|
||||||
|
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
Dprintf("pq_copy_both: consume_func returned NULL");
|
Dprintf("pq_copy_both: consume returned NULL");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
Py_DECREF(tmp);
|
Py_DECREF(tmp);
|
||||||
|
@ -1818,7 +1817,6 @@ pq_copy_both(replicationCursorObject *repl, PyObject *consume, int decode,
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
Py_XDECREF(consume_func);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user