Commit c9578c5a authored by Antoine Millet's avatar Antoine Millet
Browse files

[bug#3903] Added a clean_ttls method called on unregister.

parent 0c0b3a52
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ class ObjectsDB(object):
            if obj_id in self._objects:
                self.unregister_children(obj_id)
                del self._objects[obj_id]
                self.clean_ttls(obj_id)
            else:
                raise ValueError('The object is not registered')

@@ -278,9 +279,20 @@ class ObjectsDB(object):
                for key, obj in self._objects.items():
                    if obj.get('__parent') is parent:
                        del self._objects[key]
                        self.clean_ttls(obj['id'])
            else:
                raise ValueError('The object %r is not registered' % obj_id)

    def clean_ttls(self, obj_id):
        '''
        Remove TTLs for all tags for the specified object.
        '''

        with self._lock:
            for oid, tag in self._ttls.keys():
                if oid == obj_id:
                    del self._ttls[(oid, tag)]

    def get_ids(self):
        '''
        Get the set of all the first level ids.