diff --git a/splunklib/searchcommands/generating_command.py b/splunklib/searchcommands/generating_command.py index 33426544..1de90354 100644 --- a/splunklib/searchcommands/generating_command.py +++ b/splunklib/searchcommands/generating_command.py @@ -208,17 +208,13 @@ def _execute(self, ifile, process): def _execute_chunk_v2(self, process, chunk): count = 0 - records = [] for row in process: - records.append(row) + self._record_writer.write_record(row) count += 1 - if count == self._record_writer._maxresultrows: + if count == self._record_writer.maxresultrows: break - for row in records: - self._record_writer.write_record(row) - - if count == self._record_writer._maxresultrows: + if count == self._record_writer.maxresultrows: self._finished = False else: self._finished = True diff --git a/splunklib/searchcommands/internals.py b/splunklib/searchcommands/internals.py index 40e46855..e9aa15ea 100644 --- a/splunklib/searchcommands/internals.py +++ b/splunklib/searchcommands/internals.py @@ -462,6 +462,10 @@ def __init__(self, ofile, maxresultrows=None): self._committed_record_count = 0 self.custom_fields = set() + @property + def maxresultrows(self): + return self._maxresultrows + @property def is_flushed(self): return self._flushed @@ -527,7 +531,8 @@ def write_record(self, record): def write_records(self, records): self._ensure_validity() - records = [] if records is NotImplemented else list(records) + if records is NotImplemented: + return write_record = self._write_record for record in records: write_record(record)