Re: conn.close() idempotence

Daniele Varrazzo <[email protected]>
Newsgroups gmane.comp.python.db
Message-ID <CA+mi_8bJq45YAQA7OTFOe+6v3vaTmbf-8eX+0j1fbait1BtJfw@mail.gmail.com>
On Wed, Oct 19, 2011 at 9:49 AM, M.-A. Lemburg <[email protected]> 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
_______________________________________________
DB-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/db-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.