Hello All,

I have a situation like this :

Thread T1, has session T1Session.
Thread T2, has session T2Session. They both bind to the same database.

Now, I have scenario like below :

u1 = User(1111)
u2 = User(2222)
u3 = User(3333)    #All these are Entity objects, 1111, 2222 and 3333 are
primary keys.

T1Session.add( < u1, u2 and u3 > )
T1Session.flush()
T1Session.commit()
# T1Session.identity_map will have the 3 user objects.

li = T2Session.Query(Users).all()
for u in li:
  T2Session.delete(u)
  T2Session.flush()
  T2Session.commit()

#But T1Session.identity_map still has the 3 user objects.
a = User(1111)
b = User(2222)
T1Session.add(a)
T1Session.add(b)
T1Session.flush()
>>> Throws an exception :
    raise exc.FlushError("New instance %s with identity key %s conflicts
with persistent instance %s
" % (state_str(state), str(instance_key), state_str(existing)))
>>>

Clearing T1Session before adding a and b would work. But I dont have that
much control over T1Session, and setting up a mechanism to do this will turn
to be very complicated in my app's scenario. Is there any way to make
T1Session aware that it has invalid data in its identity_map immediately
after T2Session deleted those users?

Thanks for the help!

Cheers,
Harish

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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