Teemu Yli-Elsilä wrote: > > Hello, > > I'm deploying a Pylons/TG app that uses SQLAlchemy into a customer's > server network. Due to their network architecture, TCP sessions from SA > to the Oracle server are getting timed out by their Ciscos. My > application needs to work around this. > > I heard that Mike Bayer had stated that SQLAlchemy won't be able to cope > with database outages properly, however, the next request after a > timeout/disconnection will try again. I assume this is causing the > sporadic errors I am receiving, such as: > > "AttributeError: 'unicode' object has no attribute '_sa_instance_state'" > inside sqlalchemy.orm.attributes > > 'UndefinedError: None has no member named "name"' from a Genshi template > containing $item.name where 'item' is a model class instance.
actually no, neither of those errors would be caused by a database outage. If a connection died, an exception would be thrown and your entire request would fail with a 500 server error. Stack traces would be thrown and you'd see those very plainly in your logs. If you were wrapping the retreival of data in a try/except and then returning None if an exception occurred (an *extremely* bad idea), that might cause the second error of those two, but still not the first. > > Is there a way to configure a connection keepalive, regular pinging of > the DB, or otherwise make sure that pool connections are recycled within > a given time limit? recycle is documented at these locations: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine http://www.sqlalchemy.org/trac/wiki/FAQ#Howdoespool_recyclework http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/pooling.html#sqlalchemy.pool.QueuePool the "ping" feature you can implement using a PoolListener, which is described here (this is a more obscure feature): http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/interfaces.html#sqlalchemy.interfaces.PoolListener hope this helps. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---