Skip to content

Commit 33b5e90

Browse files
shivamsharma2106mateusz834
authored andcommitted
fix: stream records lazily in write_records and _execute_chunk_v2
1 parent 08d9cdf commit 33b5e90

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

splunklib/searchcommands/generating_command.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,12 @@ def _execute(self, ifile, process):
208208

209209
def _execute_chunk_v2(self, process, chunk):
210210
count = 0
211-
records = []
212211
for row in process:
213-
records.append(row)
212+
self._record_writer.write_record(row)
214213
count += 1
215214
if count == self._record_writer._maxresultrows:
216215
break
217216

218-
for row in records:
219-
self._record_writer.write_record(row)
220-
221217
if count == self._record_writer._maxresultrows:
222218
self._finished = False
223219
else:

splunklib/searchcommands/internals.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@ def write_record(self, record):
527527

528528
def write_records(self, records):
529529
self._ensure_validity()
530-
records = [] if records is NotImplemented else list(records)
530+
if records is NotImplemented:
531+
return
531532
write_record = self._write_record
532533
for record in records:
533534
write_record(record)

0 commit comments

Comments
 (0)