Fernando Takai wrote:
>
> Hi all!
>
> I've experiencing this problem for some time now and even after
> debugging, i could not find why it happens.
>
> I have a medium sized multi-thread application that manipulates
> SQLAlchemy objects - the objects are passed from thread to thread, so,
> when i load an instance i close the session.
>
> After working on the object, i need to update the status of the it, so
> i do something like this:
>
> job.status = FINISHED
> session.add(job)
> log.info("Finished job %s" % job.filename)
> session.flush()
>
> This code works pretty well, but from time to time, i get this on the
> logs:
>
> "UnboundExecutionError: Instance <Job at 0x413ee50> is not bound to a
> Session; attribute refresh operation cannot proceed"
>
> The complete stacktrace is here: http://pastebin.org/54196
>
> Could this be happening because of my pool_recycle setting (300
> seconds) ?its not related to the pool. Your objects have expired or unloaded attributes present on them which will attempt to load when accessed. The object must be attached to a Session for this to proceed. the easiest way to deal with this is to merge() the objects into a new thread-local Session before using. Alternatively, ensure all required attributes are loaded. This often requires touching the attributes explicitly in the case of joined table inheritance or lazily-loaded relations(). Also note that calling session.commit() or session.rollback() expires all attributes, so avoid these in the case of objects becoming detached, or expunge() the objects before an expiration occurs. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
