From a8ef13620a2c95ec83a5298d68ae2b6195965098 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 24 Feb 2014 11:39:43 +0000 Subject: [PATCH] Set the connection async earlier in green mode The moment it is called shouldn't have really changed, but it's more explicit when it happens. Previously it was sort of obfuscated behind a roundtrip through the green callback and poll. --- psycopg/connection_int.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 5069e640..51ebfd28 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -506,10 +506,6 @@ conn_setup(connectionObject *self, PGconn *pgconn) pthread_mutex_lock(&self->lock); Py_BLOCK_THREADS; - if (psyco_green() && (0 > pq_set_non_blocking(self, 1))) { - return -1; - } - if (!conn_is_datestyle_ok(self->pgconn)) { int res; Py_UNBLOCK_THREADS; @@ -573,6 +569,9 @@ _conn_sync_connect(connectionObject *self) /* if the connection is green, wait to finish connection */ if (green) { + if (0 > pq_set_non_blocking(self, 1)) { + return -1; + } if (0 != psyco_wait(self)) { return -1; }