From: | Mark Theisen <mark(dot)theisen(at)digitecinc(dot)com> |
---|---|
To: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
Cc: | "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org> |
Subject: | Re: connection already closed error |
Date: | 2011-10-18 15:21:27 |
Message-ID: | 7197F80C5AE6E943AF2CC4067B22FBD4BD0DD3F061@OMALINMAIL01.lindsaymfg.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
Also, are you are using a pooling middleware (pgpool) with a python pool (Twisted's)?
Yes, I have multiple programs that will use the twisted pool, but they all connect to the pgpooler.
Am I understanding right that "twistedpg" is some module of yours?
Not really, I found it at http://twistedmatrix.com/pipermail/twisted-python/2006-April/012955.html
________________________________________
From: Daniele Varrazzo [daniele(dot)varrazzo(at)gmail(dot)com]
Sent: Tuesday, October 18, 2011 10:11 AM
To: Mark Theisen
Cc: psycopg(at)postgresql(dot)org
Subject: Re: [psycopg] connection already closed error
On Tue, Oct 18, 2011 at 3:32 PM, Mark Theisen
<mark(dot)theisen(at)digitecinc(dot)com> wrote:
Hi Mark,
> I am using python2.6 with twisted 10.1.0 and psycopg2 2.2.1. We are also using pgpooler with transaction pool mode set. I am using the twisted ConnectionPool and twistedpg.py, which is:
I'm afraid we don't maintain Twisted ConnectionPool. Also, are you are
using a pooling middleware (pgpool) with a python pool (Twisted's)?
This is at best redundant, at worse undefined.
Am I understanding right that "twistedpg" is some module of yours?
Googling for it, it suggest me that I wanted to look for "twisted
pig", which I would prefer to avoid.
> I am getting this error when we restart pgpool:
> [...]
> conn.close()
> psycopg2.InterfaceError: connection already closed
It doesn't surprise me so much.
> Would a possible solution be to change twistedpg.py to:
> def close(self):
> try:
> _2connection.close(self)
> except psycopg2.InterfaceError:
> pass
It seems so. You could also use "if not self.closed:
_2connection.close(self)" (if you have this attribute exposed... why
not just self.close()?). However, I think there is not really a reason
for which conn.close() should raise an error on a closed connection:
it is an idempotent method.
/me looks at the dbapi...
uhm, it doesn't explicitly require that. I think a more robust close()
should just return if the connection is closed. It shouldn't raise
exceptions, as in turn PQfinish doesn't. Oh yes, I see: we used to
execute a ROLLBACK on close() so we needed the connection to be open
to be properly closed... but we don't do this anymore. Currently we do
little more than calling PQfinish, which never fails (well, not
politely at least).
Fog, whaddyathink: "conn.close(); conn.close()" should raise an
exception or should just return?
-- Daniele
From | Date | Subject | |
---|---|---|---|
Next Message | Federico Di Gregorio | 2011-10-18 15:38:16 | Re: connection already closed error |
Previous Message | AM | 2011-10-18 15:20:01 | Re: connection already closed error |