@classmethod
def add_finalizer(cls, id, weak_ref):
    """Registers a finalizer with an id.

        :param id: The id of the object referenced by the weak reference.
        :param weak_ref: The weak reference to register.
        """
    with cls.lock:
        cls.finalizers[id] = weak_ref
