def exception_storm(): my_name = threading.current_thread().name my_ident = threading.current_thread().ident i = 0 from weakref import WeakValueDictionary d = WeakValueDictionary() k = C() v = C() d[k] = v x = C() while not thread_abort: d.__contains__(x) i += 1 if i % 10000 == 0: print('{} [{}] processed {} exceptions'.format(my_name, my_ident, i)) print("Exiting")
def __contains__(self, key): return WeakValueDictionary.__contains__(self, freeze(key))
def __contains__(self, key): if isinstance(key, bytes): key = key.decode("utf-8") return WeakValueDictionary.__contains__(self, key)