> -----Original Message-----
> From: webware-devel-admin@...
> [mailto:webware-devel-admin@... Behalf Of Chuck
> Sent: Sunday, November 09, 2003 1:11 PM
> To: webware-devel@...
> Cc: andy@...
> Subject: RE: [Webware-devel] MiddleKit & MySQLdb 0.9.2 problem
> On Sun, 9 Nov 2003 01:56:40 -0800, Ben Parker wrote:
> > FWIW, if you close the connection before reassigning the variable
> > to a new connection, your test script succeeds on my system (RedHat
> > 7.3, MySQLdb 0.9.2, mysql 4.0.13-standard, python 2.2.3). Just add
> > "conn.close()" at the end of the body of the for loop.
> > It seems like the __del__ method isn't being called when the conn
> > variable is reassigned to the new connection. It could be that
> > MySQLdb keeps an internal reference to the connection so the
> > reference count does drop to 0 when the conn variable is
> ^ not
> > reassigned. I have not reviewed the MySQLdb code so that's only a
> > guess.
> > We have had a bunch of issues with memory leaks due to unclosed db
> > connections using MySQLdb 0.9.2. It's now strict policy in code
> > reviews to make sure all db connections and cursors are explicitly
> > closed using <connection>.close().
> In my real application, the method that creates the connection
> lives in a library and returns the connection so that it can be
> optionally reused. So I don't know if there is a straightforward
> fix in my situation. For now, I'm using 0.9.1.
Argh!, apologies for the dropped word there. funny how 3 letters can change
the whole meaning of a sentence...
Yeah, it's tough having optionally reusable connections. You may want to
consider having a pool for reusable connections and a separate method for
opening a single-use connection which will be closed by the thread that