On Jun 18, 2009, at 1:02 AM, Michael Mileusnich wrote:

> I know I have asked this before but I would like some clarification.
>
> If I do something like :
>
> i = query(table).all
> for instance in i:
>
> thread_class(i.ID)
> thread_class.start()
> del thread_class
>
>
> and do an additional query in the init of the thread_class to pull  
> up the entire record for i using the ID passed into variable  
> fetch_i, can I do sess.flush() and fetch_i be updated?  I am using a  
> scoped session and sometimes I get the following error:
>
> Traceback (most recent call last):
>   File "D:\Python26\lib\threading.py", line 522, in __bootstrap_inner
>     self.run()
>   File "C:\Dev\jlaunch.py", line 253, in run
>     self.sess.flush()
>   File "d:\python26\lib\site-packages\sqlalchemy-0.5.3-py2.6.egg 
> \sqlalchemy\orm\
> session.py", line 1347, in flush
>     raise sa_exc.InvalidRequestError("Session is already flushing")
> InvalidRequestError: Session is already flushing
>
> Am I going about this wrong?

its not at all clear what you're doing here but Sessions are not  
threadsafe in any case so you cannot access them via multiple threads  
without applying locking to all operations.   Using the ScopedSession,  
each thread should call Session() itself (or use the class-level  
accessors) so that individual sessions are not shared among threads.


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