On Sat, 28 Jul 2007 14:36:45 -0000
Michael Bayer <[EMAIL PROTECTED]> wrote:

> 
> your best option is probably to keep the objects in a session that's
> specifically for the "global" objects.  Most important is that if you
> are using multiple threads, you never call flush() on this session.
> With regards to threadsafety in this case, as long as the session is
> not used for a flush() operation, you should be OK.  The connection
> used for querying for a non-transactional session is checked out
> distinctly per-operation, so there will be no conflicts there.  The
> second place of concern is when the Query retrieves existing objects
> from the identity map as it loads rows, and as it places newly loaded
> objects into the identity map;  multiple threads might both create the
> same object and might both store it in the identity map; only one
> would actually remain in the map.  However for a purely read-only
> situation, your application will still see the same kinds of objects,
> and even the object that was "replaced", which still would remain
> established in a parent collection, can still call upon that session
> to issue further lazyloads.
> 
> I might look into adding a flag in 0.4 session "readonly", which
> produces a session that disallows flush() and places a single mutex
> around query.instances(); then youd have a completely threadsafe read-
> only session.  its only a couple of lines.

Sorry if this is naive.. but.. if the data is 'readonly' and can not
be flushed, why keep the very valuable thread, session, and db
connection open?  Why not just load data into a global variable and be
done with it?


-- 

michael



--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to