docs: def RunStateMethod(self,
                       method_name,
                       request=None,
                       responses=None,
                       event=None,
                       direct_response=None):
      """Completes the request by calling the state method.
  
      Args:
        method_name: The name of the state method to call.
        request: A RequestState protobuf.
        responses: A list of GrrMessages responding to the request.
        event: A threading.Event() instance to signal completion of this request.
        direct_response: A flow.Responses() object can be provided to avoid
          creation of one.
      """
      client_id = None
      try:
        self.context.current_state = method_name
        if request and responses:
          client_id = request.client_id or self.runner_args.client_id
          logging.debug("%s Running %s with %d responses from %s",
                        self.session_id, method_name, len(responses), client_id)
  
        else:
          logging.debug("%s Running state method %s", self.session_id,
                        method_name)
  
        # Extend our lease if needed.
        self.hunt_obj.HeartBeat()
        try:
          method = getattr(self.hunt_obj, method_name)
        except AttributeError:
          raise flow_runner.FlowRunnerError(
              "Flow %s has no state method %s" %
              (self.hunt_obj.__class__.__name__, method_name))
  
        if direct_response:
          method(direct_response)
        elif method_name == "Start":
          method()
        else:
          # Prepare a responses object for the state method to use:
          responses = flow_responses.Responses.FromLegacyResponses(
              request=request, responses=responses)
  
          if responses.status:
            self.SaveResourceUsage(request.client_id, responses.status)
  
          stats_collector_instance.Get().IncrementCounter("grr_worker_states_run")
  
          method(responses)
  
      # We don't know here what exceptions can be thrown in the flow but we have
      # to continue. Thus, we catch everything.
      except Exception as e:  # pylint: disable=broad-except
  
        # TODO(user): Deprecate in favor of 'flow_errors'.
        stats_collector_instance.Get().IncrementCounter("grr_flow_errors")
  
        stats_collector_instance.Get().IncrementCounter(
            "flow_errors", fields=[self.hunt_obj.Name()])
        logging.exception("Hunt %s raised %s.", self.session_id, e)
  
        self.Error(traceback.format_exc(), client_id=client_id)
  
      finally:
        if event:
          event.set()