code: def service_changed(self, event):
          # type: (ServiceEvent) -> None
          
          # Call sub-methods
          kind = event.get_kind()
          svc_ref = event.get_service_reference()
  
          if kind == ServiceEvent.REGISTERED:
              # Service coming
              with self.__instances_lock:
                  self.__add_handler_factory(svc_ref)
  
          elif kind == ServiceEvent.UNREGISTERING:
              # Service gone
              with self.__instances_lock:
                  self.__remove_handler_factory(svc_ref)
docs: Called when a handler factory service is un/registered