On Jun 6, 2008, at 3:14 PM, Venkatesh wrote:

>
> Hello,
> I'm trying to use SQLAlchemy for my Python project which is a multi-
> threaded application. While I've had good success in performing CRUD
> operations with a single thread, I'm having a lot of trouble when I
> start using multiple threads.
>
> Can anybody give a simple example of using the Session in a multi
> threaded context? I'm looking for a simple example like this:
>
> class User(object):
> - this is the User class which has the users_table
>
> class ThreadOne
> - open a thread local session
> - perform operations on user objects
> - save the user object
>
> class ThreadTwo
> - open another thread local session
> - connect to the same db, and get user objects
> - modify the user objects
> - save this to the db
>


use one session per thread, share nothing between threads.  The  
scoped_session should make this pretty straightforward.

http://www.sqlalchemy.org/docs/04/session.html#unitofwork_contextual




--~--~---------~--~----~------------~-------~--~----~
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