On Aug 5, 2006, at 12:30 PM, Tzahi Fadida wrote: > On Saturday 05 August 2006 17:42, Michael Bayer wrote: >> well, if your app has SessionTransactions lying around that dont have >> an explicit commit() or rollback(), thats a situation that should be >> corrected in your application. gc.collect() is a heavy operation >> best managed by the python interpreter in normal circumstances. > > My framework hosts projects, i.e. it is not exactly sound to assume > that all > the projects are bug free. If i had to assume that, the downtime > would be > considerable.
if people create projects that have bugs in them, why is it not reasonable that the application would be buggy ? > Anyway, i am trying to do something with this issue by doing > gc.collect() > when no connections are left. > My first question, is how do i make a generic pool. both for > PostgreSQL, > mysql, etc... Specifically i am more interested in how to define > max_overflow, pool_size and not necessarily saying what database i > am working > with. (though push comes to shove my expertise is on PostgreSQL so...) > the pool doesnt actually know much about connections and just receives a callable function to create them. so, put whatever you want into that callable. its not going to work very well to have a single pool return different kinds of connections, though. > And the second question, i wish to block until i get a connection > but do > answer to timeouts so my idea is to touch the database when i am > creating a > transaction and block until a connection is available: > u1 = None > while not u1: > try: > u1=query.select(User.c.user_id==3)[0] > except TimeoutError: > gc.collect() > > What i am seeking is to replace the line: > u1=query.select(User.c.user_id==3)[0] > with a generic touch for all databases method so that the session > will attempt > to connect. sorry, i have no idea what "a generic touch for all databases" means. > > p.s.: i tried to do the blocking in a custom pool but the queuepool > checkedin() is apparently unreliable because naturally Queue qsize is > unreliable. > If there was, besides the getconn (custom connection), maybe > something like > endedconnection, i could use a BoundedSemaphore on it. OK, this also sounds like an idea you have, that you should probably try to implement on your own...it sounds totally different from the pool that is provided with SA. you are free to make your own pool class that does whatever you need it to (either subclassing Pool, which is mostly generic, or just totally your own thing; the rest of SA doesnt really care); it can be used within a regular ComposedSQLEngine. if you come up with some better ways to synchronize/block/etc., we'd be interested to see what it looks like. the current pool implementation is trying to keep it as simple as possible for the vast majority of projects, which includes a handful of web frameworks (like, turbogears, pylons) for which its been working out mostly OK. ------------------------------------------------------------------------- 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