The code bellow throwing error "ObjectDeletedError: Instance 'xxx' has been 
deleted." when an exception throwing from "method1".

How fix this issue.


def main_method():
    DBSession.add(db_obj1)
    DBSession.fush()

    for x in lst:
        method1(db_obj1.id)


def method1(id):
    try:    
        s1 = DBSession()
        s1.begin_nested()

        db_obj2 = create_new_obj(id)
        DBSession.add(db_obj1)
        DBSession.fush()

        if some-codition:
            raise Exception("Failedd")

        s1.commit()
    except Exception, ex:
        s1.rollback()
        raise ex

-- 
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/-/VGUXlX9cevoJ.
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.

Reply via email to