Persistent object in volatile dictionary on a per thread basis
Hi all. I would like to know if it can be considered safe to keep an object in a volatile (i.e. non persistent) dictionary, one for each thread. Is it possible to have the dreaded error, i.e. exceptions.RuntimeError Shouldn't load state for 0x01254260 when the connection is closed Thanks for your support. Regards Marco -- Marco Bizzarri http://iliveinpisa.blogspot.com/
On 11/20/06, Marco Bizzarri <marco.bizzarri@gmail.com> wrote:
I would like to know if it can be considered safe to keep an object in a volatile (i.e. non persistent) dictionary, one for each thread.
Yes, it is perfectly legal. All attributes starting with _v are considered volatile and won't be persisted, including dictionaries stored as such attributes.
Is it possible to have the dreaded error, i.e.
exceptions.RuntimeError Shouldn't load state for 0x01254260 when the connection is closed
That error would not be connected to _v volatile attributes, as they are skipped when storing and are therefor not present when loading. The error has to do with a closed ZODB database connection instead, for whatever reason. -- Martijn Pieters
Marco Bizzarri wrote at 2006-11-20 11:06 +0100:
I would like to know if it can be considered safe to keep an object in a volatile (i.e. non persistent) dictionary, one for each thread.
You can keep objects in a volatile dictionary -- but they must not be persistent (unlike you put them into a "_v_*" variable. A persistent object can only be used in the context of the ZODB connection that loaded it.
.... exceptions.RuntimeError Shouldn't load state for 0x01254260 when the connection is closed
That's one of the possible problems when you violate the above restriction. -- Dieter
participants (3)
-
Dieter Maurer -
Marco Bizzarri -
Martijn Pieters