heres another patch that is probably better, does not require an explicit step on your part as it does a cleanup pass, checked in to rev 1765. see if this one works out, a test program on this end created 50 threads and maintained a size of 5 connections. fortunately sqlite is pretty casual/fast about connections and we probably could just have a straight connect/disconnect module with more or less the same performance, if it werent for :memory: connections. Index: lib/sqlalchemy/pool.py =================================================================== --- lib/sqlalchemy/pool.py (revision 1764) +++ lib/sqlalchemy/pool.py (working copy) @@ -184,10 +184,11 @@ class SingletonThreadPool(Pool): """Maintains one connection per each thread, never moving to another thread. this is used for SQLite.""" - def __init__(self, creator, **params): + def __init__(self, creator, pool_size=5, **params): Pool.__init__(self, **params) self._conns = {} self._creator = creator + self.size = pool_size def dispose(self): for key, conn in self._conns.items(): @@ -203,7 +204,16 @@ del self._conns[thread.get_ident()] except KeyError: pass - + + def cleanup(self): + for key in self._conns.keys(): + try: + del self._conns[key] + except KeyError: + pass + if len(self._conns) <= self.size: + return + def status(self): return "SingletonThreadPool id:%d thread:%d size: %d" % (id(self), thread.get_ident(), len(self._conns)) @@ -222,6 +232,8 @@ except KeyError: c = self._creator() self._conns[thread.get_ident()] = c + if len(self._conns) > self.size: + self.cleanup() return c class QueuePool(Pool): On Aug 5, 2006, at 2:11 AM, [EMAIL PROTECTED] wrote: We're about ready to go to production with our new website (built using pylons, sqlalchemy 0.2.6/sqlite, and kid), so I thought I would point apachebench at it to see how things performed. I was horrified to see memory consumption going through the roof (i.e. >100MB in less than 10,000 requests!). |
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users