Re: [DB-SIG] conn.close() idempotence

2011-10-19 Thread M.-A. Lemburg
Daniele Varrazzo wrote: > Hello, > > in a discussion on the psycopg mailing list, an user has been > surprised by the fact that .close() called on a closed connection > raised error. I thought this was an implementation accident in the > driver and a more robust semantics should allow for close to

Re: [DB-SIG] conn.close() idempotence

2011-10-19 Thread Federico Di Gregorio
On 19/10/11 09:59, M.-A. Lemburg wrote: [snip] >> risks to become a problem, with the close() that may raise an error >> > because the connection has been implicitly closed by a communication >> > error. Note that close() in itself often is a quite safe operation, >> > not involving database commun

Re: [DB-SIG] conn.close() idempotence

2011-10-19 Thread M.-A. Lemburg
Federico Di Gregorio wrote: > On 19/10/11 09:59, M.-A. Lemburg wrote: > [snip] >>> risks to become a problem, with the close() that may raise an error because the connection has been implicitly closed by a communication error. Note that close() in itself often is a quite safe operation, >

Re: [DB-SIG] conn.close() idempotence

2011-10-19 Thread Daniele Varrazzo
On Wed, Oct 19, 2011 at 8:59 AM, M.-A. Lemburg wrote: >> risks to become a problem, with the close() that may raise an error >> because the connection has been implicitly closed by a communication >> error. Note that close() in itself often is a quite safe operation, >> not involving database com

Re: [DB-SIG] conn.close() idempotence

2011-10-19 Thread M.-A. Lemburg
Thinking about this some more ... Perhaps what you're really after is the following and I was just misunderstanding the original proposal: class Connection: closed = False def close(self): if self.closed: return # close the connection ... self

Re: [DB-SIG] conn.close() idempotence

2011-10-19 Thread Daniele Varrazzo
On Wed, Oct 19, 2011 at 9:49 AM, M.-A. Lemburg wrote: > Thinking about this some more ... > > Perhaps what you're really after is the following and I was just > misunderstanding the original proposal: > > class Connection: > >    closed = False > >    def close(self): >        if self.closed: >