<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __remove_handler_factory(self, svc_ref):
 # type: (ServiceReference) -> None """ Removes an handler factory :param svc_ref: ServiceReference of the handler factory to remove """

        with self.__handlers_lock:
            # Get the handler ID
            handler_id = svc_ref.get_property(handlers_const.PROP_HANDLER_ID)

            # Check if this is the handler we use
            if svc_ref not in self._handlers_refs:
                return

            # Clean up
            self.__context.unget_service(svc_ref)
            self._handlers_refs.remove(svc_ref)
            del self._handlers[handler_id]

            # List the components using this handler
            to_stop = set()  # type: Set[StoredInstance]
            for factory_name in self.__factories:
                _, factory_context = self.__get_factory_with_context(
                    factory_name
                )
                if handler_id in factory_context.get_handlers_ids():
                    to_stop.update(self.__get_stored_instances(factory_name))

            with self.__instances_lock:
                for stored_instance in to_stop:
                    # Extract information
                    context = stored_instance.context
                    name = context.name
                    instance = stored_instance.instance

                    # Clean up the stored instance (iPOPO side)
                    del self.__instances[name]
                    stored_instance.kill()

                    # Add the component to the waiting queue
                    self.__waiting_handlers[name] = (context, instance)

            # Try to find a new handler factory
            new_ref = self.__context.get_service_reference(
                handlers_const.SERVICE_IPOPO_HANDLER_FACTORY,
                "({0}={1})".format(handlers_const.PROP_HANDLER_ID, handler_id),
            )
            if new_ref is not None:
                self.__add_handler_factory(new_ref)