code: def event(self, service_event, listener_dict):
          
          print(
              "EventListenerHookImpl: service_event=",
              service_event,
              ", listener_dict=",
              listener_dict,
              sep="",
          )
  
          # Remove it if it's our service context, has the "to_filter" property
          # and it's the 3rd time through the hook
          svc_ref = service_event.get_service_reference()
          to_filter = svc_ref.get_property("to_filter")
          if self._context in listener_dict and to_filter:
              if self._count >= 3:
                  print(
                      "EventListenerHookSample removing our service listener "
                      "so it will not be notified"
                  )
                  listener_dict.pop(self._context)
              else:
                  self._count += 1
docs: A service has been received: this method can alter the list of
          listeners to be notified of this event (remove only).
          It can also be used as a handler for the event that will be called
          before any standard one.
  
          :param service_event: The ServiceEvent being triggered
          :param listener_dict: A dictionary associating a bundle context to a
                                list of listeners