Excceptions make me nervous.
Exceptions are your friend! They're so warm and cuddly they shouldn't frighten anyone. :)
FWIW. I think the ping() based implementation is probably the best one to go for, because it doesn't raise any exceptions (so say the MySQL[db] docs, anyway), and it automagically reconnects internally to MySQL's own code if it can. No point in making work for ourselves, eh? ;-)
It all depends. Catching the exception might actually be less work because you're assuming that most of the time the connection is good, so you don't need the extra ping. You only need it when the connection is timed out.
Swings and roundabouts I guess. ping() is a pretty low overhead call as I understand it, so there's not much in it.
Without connection cacheing though, it takes three times longer to initialize a list and start mailing (that's for a 60,000 member list).
If you're not totally appauled by the code quality, and you think it'll work, let me know, and (if necessary) I'll upload it to the sourceforge site patches section, from which you may apply a GPL license to it (as far as I'm concerned, and I think it's safe from the perspective of the related software, etc.), and do what you wish with it, as long as it's appropriately credited, and, for preference continues to include a link to http://www.orenet.co.uk/ in it.
Cool, thanks. Do upload it. Done.
It's in as "[ 839386 ] MySQL MemberAdaptor for Mailman 2.1".
If we decide to use it, we'll probably need some kind of more formal disclaimer. Shouldn't be a problem, as long as I don't have to guarantee it'll work flawlessly ;-)
IIRC the only code that I've used in anything approaching a direct cut+paste job came from Mailman's CVS anyway, so it should all be fine.
In the meantime, it's a useful place for others to find it. Indeed.
K.
-- Kev Green, aka Kyrian. E: kyrian@ore.org WWW: http://kyrian.ore.org/ ISP/Perl/PHP/Linux/Security Contractor, via http://www.orenet.co.uk/ "Love is that condition in which the happiness of another person is essential to your own." R. Heinlein, Stranger in a Strange Land, 1961.
Kev Green, aka Kyrian. "Be excellent to each other" -- Bill & Ted. Email: kyrian@ore.org Web: http://kyrian.ore.org/ ISP/Perl/PHP/Linux/Security Contractor, via http://www.orenet.co.uk/