__del__ method of utils.ThreadedDict #75

Open
lovelylain opened this Issue Jun 21, 2011 · 0 comments

Comments

Projects
None yet
1 participant

__del__ method of utils.ThreadedDict is not needed or should use weakref instead.
Because ThreadedDict._instances has kept a reference of ThreadedDict instances, the __del__method will not automatically be called, I also think we should not directly override threading.local's**del**.
If we use weakref, it can be like this:

_instances = set()

def __init__(self):
    ThreadedDict._instances.add(weakref.ref(self, ThreadedDict._instances.remove))

@staticmethod
def clear_all():
    for d in ThreadedDict._instances:
        d().clear()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment