def AddResultsToCollection(self, responses, client_id):
    if responses.success:
      with self.lock:
        self.processed_responses = True

        msgs = [rdf_flows.GrrMessage(payload=response, source=client_id)
                for response in responses]
        try:
          with aff4.FACTORY.Open(self.state.context.results_collection_urn,
                                 hunts_results.HuntResultCollection.__name__,
                                 mode="rw",
                                 token=self.token) as collection:
            for msg in msgs:
              collection.Add(msg)
        except __HOLE__:
          aff4.ResultsOutputCollection.AddToCollection(
              self.state.context.results_collection_urn, msgs,
              sync=True, token=self.token)

        if responses:
          self.RegisterClientWithResults(client_id)

        # Update stats.
        stats.STATS.IncrementCounter("hunt_results_added",
                                     delta=len(msgs))
    else:
      self.LogClientError(client_id, log_message=utils.SmartStr(
          responses.status))
dataset/ETHPy150Open google/grr/grr/lib/hunts/implementation.py/GRRHunt.AddResultsToCollection