I am occassionally and randomly getting a DetachedInstanceError when I try to 
access an object atttribute that is a reference. I will run this several 
thousand times and only get it twice. What I don't understand is I use the same 
exact base query, which is where the reference takes place, and it works fine. 
Then I call a function which does some calculations and then it creeps up. I 
don't close or commit the sesssion or anything weird.

I did some research about this error, and some possible causes are duplicate 
sessions and using the default expire_on_commit. I've updated my call to 
session_maker to set expire_on_commit to False. And although I'm using 
MultiProcessing and creating a new scopped_session for each instance, the only 
conclusion I can come to is this is causing the problem, but why only 
occassionally? The retreival of the problem object and all the proceding 
function calls happen in the same process, so I'm stuck looking for other 
solutions.

I've tried calling session.merge() on the problem object and I have the same 
problem.

So I'm wondering what could also cause a problem like this or what shouldn't I 
be doing that would cause this?

There is a lot of code and it isn't anywhere public and I havn't been able to 
make a minimial example, but this is a snippet of the problem code:
https://gist.github.com/edrahn/ec4b1b757313a0f5c3c3

And here is one of the tracebacks:
https://gist.github.com/edrahn/bcc1aba82b3c70168a43

Let mw know if you need anything else!


Thanks.
-- 
Ed Rahn <edsr...@gmail.com>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to