Skip site navigation (1) Skip section navigation (2)

Connection failures when using green

From: Alexey Borzenkov <snaury(at)gmail(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Connection failures when using green
Date: 2013-07-21 14:33:15
Message-ID: CAKwjivd9xb=oYc6zAk1HtHA0UguEjyHYnjq7TrZ9HSdhCwGeQg@mail.gmail.com (view raw or flat)
Thread:
Lists: psycopg
Hi,

I'm starting to use psycopg2 together with greenlet/gevent and I noticed
that when green psycopg2 connection errors are useless, since they always
raise "asynchronous connection failed" exception and there's no way to know
what exactly went wrong. Turns out that the patch for this is trivial
(which I'm using), but I'm wondering if there's some underlying reason it
wasn't done like that in the first place?

diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c
index 7851b0a..feb4196 100644
--- a/psycopg/connection_int.c
+++ b/psycopg/connection_int.c
@@ -656,7 +656,7 @@ _conn_poll_connecting(connectionObject *self)
         break;
     case PGRES_POLLING_FAILED:
     case PGRES_POLLING_ACTIVE:
-        PyErr_SetString(OperationalError, "asynchronous connection
failed");
+        PyErr_SetString(OperationalError, PQerrorMessage(self->pgconn));
         res = PSYCO_POLL_ERROR;
         break;
     }

Best regards,
Alexey.

Attachment: psycopg2-async-connect.patch
Description: application/octet-stream (511 bytes)

Responses

psycopg by date

Next:From: Daniele VarrazzoDate: 2013-07-21 17:35:20
Subject: Re: Connection failures when using green
Previous:From: Christophe PettusDate: 2013-07-19 19:02:59
Subject: Re: Problem with the default registration of the JSON adapter

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group