From: | AM <agentm(at)themactionfaction(dot)com> |
---|---|
To: | psycopg(at)postgresql(dot)org |
Subject: | Re: connection already closed error |
Date: | 2011-10-18 15:20:01 |
Message-ID: | AEA6CD00-36F7-40C0-9D22-F91BDC37C2E7@themactionfaction.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On Oct 18, 2011, at 11:11 AM, Daniele Varrazzo wrote:
>
>
>> 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?
To mimic python's standard close(), it would indeed need to be idempotent.
Cheers,
M
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Theisen | 2011-10-18 15:21:27 | Re: connection already closed error |
Previous Message | Daniele Varrazzo | 2011-10-18 15:11:35 | Re: connection already closed error |