[Twisted-Python] Help w/ low adbapi connection pool limits?

Itamar Shtull-Trauring itamar at itamarst.org
Sat Jul 26 21:37:22 MDT 2003


On Sat, 26 Jul 2003 20:10:26 -0700
Steve Freitas <sflist at ihonk.com> wrote:

> from twisted.web import xmlrpc, server
> from twisted.enterprise import adbapi
> class takeOne(xmlrpc.XMLRPC):
>     def xmlrpc_dbtest(self):
>         dbpool = adbapi.ConnectionPool("pyPgSQL.PgSQL",
>         host='127.0.0.1', \
> 		user='postgres', database='template1')
> 	dbpool.connect()
>         d = adbapi.Augmentation(dbpool)
>         result = d.runQuery("select * from auth where uname='foo'")
> 	dbpool.close()
>         return result

Don't create a new database pool per request. Store one in the resource,
that is, create one __init__ and access it using self.dbpool. No need to
do connect(), either. That should solve it.

-- 
Itamar Shtull-Trauring    http://itamarst.org/
http://www.zoteca.com -- Python & Twisted consulting




More information about the Twisted-Python mailing list