code: def __unget_service_from_factory(self, bundle, reference, service=None):
          # type: (Any, ServiceReference, Any) -> bool
          
          try:
              factory, svc_reg = self.__svc_factories[reference]
          except KeyError:
              # Unknown service reference
              return False
  
          # Check the per-bundle usage counter
          try:
              counter = self.__factory_usage[bundle]
          except KeyError:
              # Unknown reference to a factory
              return False
          else:
              if counter.unget_service(factory, svc_reg, service):
                  try:
                      # No more dependency
                      reference.unused_by(bundle)
  
                      # All references have been taken away: clean up
                      if not self.__factory_usage[bundle].is_used():
                          del self.__factory_usage[bundle]
  
                      # Remove the service reference from the bundle
                      imports = self.__bundle_imports[bundle]
                      del imports[reference]
                  except KeyError:
                      # Unknown reference
                      return False
                  else:
                      # Clean up
                      if not imports:
                          del self.__bundle_imports[bundle]
  
          return True
docs: Removes the usage of a a service factory or a prototype
          service factory by a bundle
  
          :param bundle: The bundle that used the service
          :param reference: A service reference
          :param service: Service instance (for prototype factories)
          :return: True if the bundle usage has been removed