Explicitly closing connections would be a very good addition to DBUtils, I think.

I did not inspect mysqld for dangling connections; I just added explicit closing and it worked. This is why I said 'I suspect' that connections survive inside the db server; I'm not sure of it.

atexit is indeed not called when my appserver restarts. I'm not sure whether there is a clean general way to ensure finalization of the connection pool; may be just add a shutdown hook to DBUtils and leave it up to the user to ensure it is called? When using webkit, optionally pass a reference to the appserver to DBUtils and let DBUtils hook into the appserver's shutdown method?

Best, Michael

Christoph Zwerschke <cito@online.de> wrote:
Michael Palmer wrote:
> If I didn't overlook something, DBUtils doesn't close connections when the
> Python process exits.

Persistent connections are not closed, only pooled connections are
closed. DBUtils relies on the connections being automatically closed
anyway by the dbapi module when Python exits and the connection objects
are deleted. Maybe this is a problem of MySQLdb specifically or the GC
does not work as expected on exit?

What happens if you simply open a MySQLdb connection with Python, do not
close it and exit Python, is it still there?

Anyway, I should probably add a destructor to DBUtils SteadyConnections
and also since one should not rely on GC, something to explicitely close
them on exit.

> I use a homegrown scheme for connection persistence now - it
> explicitly closes all persistent connections when Python exits.

How are you doing this? Are you using an atexit exit handler? But that
will not be called when Python is killed by a signal which will be most
likely the case when you use shutdown scripts.

-- Christoph

Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
Webware-discuss mailing list

Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around