From 6dd6bee2172951600e44e3275b48b6d852098b8e Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 3 Apr 2010 22:27:22 +0100 Subject: [PATCH] Added async read support to 'connection.poll()'. --- psycopg/connection_int.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 049efa0b..ca6cf6a2 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -696,6 +696,29 @@ conn_poll_green(connectionObject *self) } break; + case CONN_STATUS_READY: + case CONN_STATUS_BEGIN: + Dprintf("conn_poll: status = CONN_STATUS_READY/BEGIN"); + switch (self->async_status) { + case ASYNC_READ: + if (0 == PQconsumeInput(self->pgconn)) { + PyErr_SetString(OperationalError, PQerrorMessage(self->pgconn)); + res = PSYCO_POLL_ERROR; + } + if (PQisBusy(self->pgconn)) { + res = PSYCO_POLL_READ; + } else { + res = PSYCO_POLL_OK; + } + break; + + default: + Dprintf("conn_poll: in unexpected async status: %d", + self->async_status); + res = PSYCO_POLL_ERROR; + } + break; + default: Dprintf("conn_poll: in unexpected state"); res = PSYCO_POLL_ERROR;