[entropy.cache] handle TypeError exceptions when copy.deepcopy() raises it

This commit is contained in:
Fabio Erculiani
2009-10-27 21:28:08 +01:00
parent d1e47f79da
commit 7a967cd873
+9 -2
View File
@@ -15,7 +15,7 @@
entropy.client.interfaces.cache mixin methods)
"""
import sys
from entropy.core import Singleton
from entropy.misc import TimeScheduled, Lifo
import time
@@ -219,7 +219,14 @@ class EntropyCacher(Singleton):
return
if async:
with self.__cache_lock:
self.__cache_buffer.push((key, self.__copy_obj(data),))
try:
self.__cache_buffer.push((key, self.__copy_obj(data),))
except TypeError:
# sometimes, very rarely, copy.deepcopy() is unable
# to properly copy an object (blame Python bug)
sys.stdout.write("!!! cannot cache object with key %s\n" % (
key,))
sys.stdout.flush()
else:
self.dumpTools.dumpobj(key, data)