<p>I have developed some custom DAO-like classes to meet some very specialized requirements for my project that is a server-side process that does not run inside any kind of framework.  </p>

<p>The solution works great except that every time a new request is made, I open a new connection via MySQLdb.connect.  </p>

<p>What is the best "drop in" solution to switch this over to using connection pooling in python?  I am imagining something like the commons DBCP solution for Java.  </p>

<p>The process is long running and has many threads that need to make requests, but not all at the same time... specifically they do quite a lot of work before brief bursts of writing out a chunk of their results.</p>

<p>Edited to add:
After some more searching I found <a href="http://furius.ca/antiorm/" rel="noreferrer">anitpool.py</a> which looks decent, but as I'm relatively new to python I guess I just want to make sure I'm not missing a more obvious/more idiomatic/better solution.  </p>

Wrap your connection class.
Set a limit on how many connections you make.
Return an unused connection.
Intercept close to free the connection.
Update:
I put something like this in dbpool.py:
```
```
import sqlalchemy.pool as pool
import MySQLdb as mysql
mysql = pool.manage(mysql)
```
```