<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _unregister_bundle_factories(self, bundle):
 # type: (Bundle) -> None """ Unregisters all factories of the given bundle :param bundle: A bundle """

        with self.__factories_lock:
            # Find out which factories must be removed
            to_remove = [
                factory_name
                for factory_name in self.__factories
                if self.get_factory_bundle(factory_name) is bundle
            ]

            # Remove all of them
            for factory_name in to_remove:
                try:
                    self.unregister_factory(factory_name)
                except ValueError as ex:
                    _logger.warning(
                        "Error unregistering factory '%s': %s", factory_name, ex
                    )