robert wrote: > >> Is a copy.deepcopy ( -> "cPickle.dump(copy.deepcopy(obj),f)" ) an >> atomic opertion with a guarantee to not fail? >> >> Or can I only retry several times in case of RuntimeError? (which >> would apears to me as odd gambling; retry how often?) > > > For an intermediate solution, I'm playing roulette: > > for i in 1,2,3: > try: > cPickle.dump(obj, f) > break > except RuntimeError,v: > pass >
hmm.. for i in 1,2,3: try: cPickle.dump(obj, f) break except RuntimeError,v: f.seek(0);f.truncate(0) Meanwhile I think this is a bug of cPickle.dump: It should use .keys() instead of free iteration internally, when pickling elementary dicts. I'd file a bug if no objection. Robert > I hope this works for some million years ... > > > >> PS: Zope dumps thread exposed data structes regularly. How does the >> ZODB in Zope handle dict/list changes during its pickling operations? -- http://mail.python.org/mailman/listinfo/python-list