Hi Mike, It is an edge case for sure. I'm using SA with eventlet so the session is going out of scope in a green thread. Eventlet does some monkeying (literally) around with threadlocals so I get a different session for each one. However in this case the parent instance to which I'm adding obj was fetched in a one greenthread and the child is added in another after a timer has fired off (the child is a record of the timer running). It's definitely fair to say that I'm not using SA in an optimal way, however I'd still be inclined to say that the patch could be worthwhile here.
I should also have mentioned that the original session would have been from a query_property rather than an explicitly created Session(). Is there any particular reason that you added the check where you did in the patch as opposed to the except KeyError clause in _state_session? Cheers, Ben -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/HfGgOzhCMwIJ. 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.