'Removes all registered finalizers.
:param clear_all: If `True`, all finalizers are deleted. Otherwise,
only the finalizers from an empty weak reference are deleted
(i.e., weak references pointing to inexistent objects).'

@classmethod
def clear_finalizers(cls, clear_all=False):

    with cls.lock:
        if clear_all:
            cls.finalizers.clear()
        else:
            for (id, ref) in items(cls.finalizers):
                if (ref() is None):
                    cls.finalizers.pop(id, None)
