I have a small thrift server in python that I use do some fast lookups. The server queries mysql via SqlAlchemy on the first request and shoves all returned objects into a dictionary so on subsequent requests no DB call is needed. I just get the object from the dict and then call some of the object methods needed to give the proper response.
Initially, everything is fine. However, after the server runs a while, I am getting this exception when accessing the sqlalchemy object methods:
Parent instance is not bound to a Session; lazy load operation of attribute 'rate' cannot proceed.
Strange, because I set eagerload('rate')
.
I cannot really see a pattern to this behavior, it only affects some objects. However, once it does affect an object it will continue to do so on each request until I restart my python server.
Any ideas?