diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-05-09 20:37:48 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-05-09 20:37:48 +0100 |
| commit | 73db6bee01fb8c04ba55a042ed59f0639bb43599 (patch) | |
| tree | abc48d65070480535d3b8536d2087885ea59dd8c /psycopg/connection_int.c | |
| parent | e29424a23037ebbd06358905982beff675ba6255 (diff) | |
| download | psycopg2-73db6bee01fb8c04ba55a042ed59f0639bb43599.tar.gz | |
Keep the connection in blocking mode unless it is not async.
Dropped set/unset nonblocking mode for copy and lobject operations:
lobjects don't work in nonblocking mode so they will hardly be supported
in green/async branches. Support for copy is still feasible, but it
will be done in other code paths (called by poll).
Diffstat (limited to 'psycopg/connection_int.c')
| -rw-r--r-- | psycopg/connection_int.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 3684cf4..31a68d5 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -265,11 +265,13 @@ conn_setup(connectionObject *self, PGconn *pgconn) pthread_mutex_lock(&self->lock); Py_BLOCK_THREADS; - if (pq_set_non_blocking(self, 1, 1) != 0) { + int green = psyco_green(); + + if (green && (pq_set_non_blocking(self, 1, 1) != 0)) { return -1; } - if (!psyco_green()) { + if (!green) { Py_UNBLOCK_THREADS; pgres = PQexec(pgconn, psyco_datestyle); Py_BLOCK_THREADS; @@ -287,7 +289,7 @@ conn_setup(connectionObject *self, PGconn *pgconn) } CLEARPGRES(pgres); - if (!psyco_green()) { + if (!green) { Py_UNBLOCK_THREADS; pgres = PQexec(pgconn, psyco_client_encoding); Py_BLOCK_THREADS; @@ -314,7 +316,7 @@ conn_setup(connectionObject *self, PGconn *pgconn) } CLEARPGRES(pgres); - if (!psyco_green()) { + if (!green) { Py_UNBLOCK_THREADS; pgres = PQexec(pgconn, psyco_transaction_isolation); Py_BLOCK_THREADS; |
