[ZODB-Dev] BTreeFolder2 causes "RuntimeError: Shouldn't load
state for"?
Syver Enstad
syver at inout.no
Thu Jul 22 04:25:18 EDT 2004
Dieter Maurer <dieter at handshake.de> writes:
> Persistent objects must never:
>
>
> * not be passed between threads
Is it okay to just read persistent objects after a thread has modified
them? Since I am using ZODB with Twisted web I am thinking of the
following scenario. Since twisted has a mainloop it would be prudent
to shuffle off a long running operation involving ZODB to a thread so
that other web requests can be handled. After the thread has finished
processing I want to display the object(s) that changed.
Sketch:
In the web page (mainloop):
Open a new connection: (I am always using setLocalTransaction to not
make the transaction thread bound). Spawn off a thread and pass the
connection to it. Set up a callback for further processing when the
thread is done.
In worker thread:
Do processing
connection.getTransaction().commit()
return interesting Persistent objects.
In the web page (mainloop):
Receive result in callback and display it (generate html).
If this is not possible I'd like to hear why.
More information about the ZODB-Dev
mailing list