I have a couple of threads that are working on the same objects,
passing them back and forth in queues. I have just started testing
with the Sqlalchemy parts turned on, and I am getting the already
attached to session message. Also of note is that I am using the
Elixir declarative layer, although I don't think that is causing the
problem. Here is a basic example of what I am doing.
queue = Queue()
class History(Entity):
status_id = Field(Integer)
text = Field(Text)
using_options(tablename='history', autosetup=True)
using_table_options(useexisting=True)
class Worker(threading.Thread):
def run(self):
items = History.query.all()
for item in item:
queue.put(item)
for i in range(pool_size):
consumer = Consumer(self.getName())
consumer.start()
class Consumer(threading.Thread):
def run(self):
item = queue.get_nowait()
if True:
item.status_id = 1
else:
item.status_id = 2
item.update()
item.flush()
when I try to update I get: InvalidRequestError: Object
'[EMAIL PROTECTED]' is already attached to session '21222960' (this is
'21223440')
any help would be greatly appreciated.
thanks,
Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---