"RuntimeError: dictionary changed size during iteration" ; Good atomic copy operations?

Tim Peters tim.peters at gmail.com
Sat Mar 11 23:07:47 CET 2006


[robert]
> ...
> PS: how does ZODB work with this kind of problem? I thought is uses cPickle?

It does.  Each thread in a ZODB application typically uses its own
connection to a database.  As a result, each thread gets its own
consistent view of database objects, which can (and routinely does)
vary across threads.  No app-level synchronization is necessary
because no sharing of in-memory objects occurs.  When N threads each
load a single persistent object from its own connection, N distinct
in-memory revisions of that object are created (one per connection ==
one per thread).  If more than one thread modifies the same persistent
object, the first thread to commit its changes "wins", and later
threads that try to commit changes to the same object may suffer a
ConflictError exception at commit time.  Between transaction
boundaries, each thread has an independent view of database state. 
Pragmatically, it's much more like programming with multiple processes
than with multiple threads.



More information about the Python-list mailing list