Implement SQLAlchemy pre-ping to detect dropped connections.

Merged username-removed-107958 requested to merge msapiro/mailman:sa-ping into master

Fixes #313 (closed)

This patch implements the SQLAlchemy pre-ping approach to detecting dropped connections to the database server.

It is not clear that it is even possible to create unit tests that test this functionality, but the patched code works and causes no regressions in existing tests. Further, manual testing as outlined in #313 (closed) indicates it is effective in addressing the issue.

When SQLAlchemy 1.2 is released and becomes a requirement, this patch can be dropped in favor of just adding a pool_pre_ping=True argument to the create_engine() call, but if not done, this patch will continue to be effective with SA 1.2.