On May 31, 2006, at 1:32 PM, Anton Krasovsky wrote:

So (correct me if I'm wrong) the Query objects
should be created in the same thread where
they going to be used?


think more in terms of a Session...which theoretically can be shared among different threads, or for which there can be multiple instances within a single thread.

The most standard model is one session per thread, which is provided when you install the "threadlocal" mod (but even then you are not precluded from using muliple sessions in one thread)....so while you can get away with thinking in terms of "use the same thread", its better to be conceptually aware of it as a Session that just happens to be associated with the current thread.

as an example, we have one user who has written a GUI-driven application with a session scope that is "per-window" as opposed to per-thread. that application probably deals with all of the sessions in the context of a single "event-loop" thread (or maybe a second application thread as well), but it has to keep track of using the correct Session for a particular operation even within one thread.

A single Session can also be used across multiple threads...the application would have to insure that only one thread modifies it at a time, including load operations as well as "cascading" operations occuring on stored instances, since its not internally thread- synchronized.




-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to