Re: "RuntimeError: dictionary changed size during iteration" ; Good atomic copy operations?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

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

From: robert <no-spam@no-spam-no-spam.com>
Date: Sat Mar 11 2006 - 12:49:14 CET

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?
Received on Sun Apr 30 11:33:37 2006