unless theres some detail missing here, you should be using  
scoped_session() so that there's one session per thread.


On Aug 2, 2009, at 5:04 PM, drakkan wrote:

>
> Hi all,
>
> I know sqlalchemy session is not thread safe but in my application I
> need to use thread,
>
> I have my session defined as following:
>
> engine = create_engine(connectionstring, echo=settings.DEBUG,
> echo_pool=settings.DEBUG,
>                                       pool_size=20, max_overflow=400)
>
> session = sessionmaker(bind=engine)
> sess=session()
>
> and I use sess to make database logic, my database is postgres
>
> In my app I launch two threads that can work the same object, suppose
> I have an object named "tr" i pass tr.id to the thread and in the
> thread I make a new query to get the object by id, additionally one
> thread make read operation and the other write operation, this seems
> not enough the database get locked and the application hang, any
> hints?
>
> thanks
> drakkan1000
> >


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