I'm pretty sure that committing in a separate thread will commit objects modified in that thread only, since SA's unit-of-work is thread-local.

Perhaps we can suggest an alternative if you give more info on what you're trying to accomplish.

On 3/28/06, Koen Bok <[EMAIL PROTECTED]> wrote:
Hmm I was too soon. This still does not work. No errors, the the db just does not get updated...

This works perfect, but no threads...

def commit_(self):
objectstore.commit()


On 29-mrt-2006, at 1:24, Jonathan Ellis wrote:

Since you don't say what your error is, I will just show how to make your code more like Python and less like Java. :)

th = threading.Thread(target=objectsore.commit, name='updating database')
th.start()

That's it!

(And you can use threading.enumerate if you need a list of threads...)

On 3/28/06, Koen Bok <[EMAIL PROTECTED]> wrote:
Hi I would like to wrap a thread around objectstore.commit () I could not get it to work.

What am I doing wrong?

class Controller(Object):

threads = []
def commit_(self):
t = CommitChanges(objectstore)
self.threads.append(t)

class CommitChanges(Thread):
def __init__ (self, objectstore):
Thread.__init__(self)
self.description = "Updating Database"
self.objectstore = objectstore
self.start()

def run(self):
self.objectstore.commit()



--
Jonathan Ellis
http://spyced.blogspot.com




--
Jonathan Ellis
http://spyced.blogspot.com

Reply via email to