[DB-SIG] conn.close() idempotence

Daniele Varrazzo daniele.varrazzo at gmail.com
Wed Oct 19 10:55:33 CEST 2011


On Wed, Oct 19, 2011 at 9:49 AM, M.-A. Lemburg <mal at egenix.com> 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:
>            return
>        # close the connection
>        ...
>        self.closed = True
>
> In other words, you don't silence any errors, but instead use
> a flag to store the successful close operation and then simply
> ignore all future calls to the method without raising an
> exception.

Yep, the idea is just this :) Seems a reasonable behaviour but it
currently raises an exception in the DBAPI unit test, which I feel a
little bit on the strict side.

-- Daniele


More information about the DB-SIG mailing list