The one (?) place that sqlalchemy pool isn't really transparent is wrt closing connections.

Consider this function --

def foo():
  conn = psycopg2.connect(...)
  c = conn.cursor()
  c.execute('select * from users')

To keep this "correct" in a pooled environment, I have to manually add "conn.rollback()" or I'll have a connection stuck in an open transaction.  In a non-pooled environment, rollback is implicitly performed.

Also, with a non-pooled connection, you can manually call close() instead of relying on refcounts to GC it eventually.  In a pooled situation this should probably return the connection to the pool, instead of really closing it.

Modifying the behavior of close() is easy but I don't see a portable way to auto-rollback.  (Other than issuing a blind rollback on every re-pool, which seems like an undesireable performance hit.)  Perhaps a disclaimer to this effect should be added to the pooling docs?

--
Jonathan Ellis
http://spyced.blogspot.com
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to