Since Version 1.41 (2008-09-11 09:56:02) web2py supports connection pooling.
At this point the feature works but it has to be considered experimental and more tests are welcome.
To use a connection pool simply specify how many items you want the pool when creating a SQLDB instance. For example:
web2py allows per app connections and multiple connections per app. Each connection uri is associated to a pool that is shared by all threads in each process.
when a model is executed, if there no open connections in the pool, web2py creates a new connection.
when a controller returns, after the transaction is committed (automatically on success) or rolledback (automatically on uncaught exception) the connection is placed back in the pool.
If pools=0, there is no pool and a new connection is established at each http request. This is not the fastest solution but it is rock solid. The default.
If pools=10, then the pool builds up over time up as needed up to 10 connections, then its size stays equal to 10 and does not exceed 10 connections. Each pool size is the minimum of the value of pools and the maximum number of concurrent http requests up to now.
If a connection crashes, it is not stored back in the pool and it does not affect other threads and http requests.
There is no mechanism to close the connections in a pool. They will close when you kill web2py.