Skip to content

Commit 5002dc6

Browse files
aijamysutedja
authored andcommitted
Fix generating commands
1 parent 2beb3e3 commit 5002dc6

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

splunklib/searchcommands/generating_command.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,6 @@ def generate(self):
195195
raise NotImplementedError('GeneratingCommand.generate(self)')
196196

197197

198-
def __generate_chunk(self, unused_input):
199-
count = 0
200-
for row in generate():
201-
yield row
202-
count += 1
203-
if count == self._record_writer._maxresultrows:
204-
# count = 0
205-
return
206198

207199
def _execute(self, ifile, process):
208200
""" Execution loop
@@ -214,12 +206,22 @@ def _execute(self, ifile, process):
214206
215207
"""
216208
if self._protocol_version == 2:
217-
self._execute_v2(ifile, self.__generate_chunk)
209+
self._execute_v2(ifile, self.generate())
218210
else:
219211
assert self._protocol_version == 1
220212
self._record_writer.write_records(self.generate())
221213
self.finish()
222214

215+
def _execute_chunk_v2(self, process, chunk):
216+
count = 0
217+
for row in process:
218+
self._record_writer.write_record(row)
219+
count += 1
220+
if count == self._record_writer._maxresultrows:
221+
self._finished = False
222+
return
223+
self._finished = True
224+
223225
# endregion
224226

225227
# region Types

splunklib/searchcommands/search_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ def _execute_v2(self, ifile, process):
945945

946946
self._execute_chunk_v2(process, result)
947947

948-
self._record_writer.write_chunk()
948+
self._record_writer.write_chunk(finished=self._finished)
949949

950950
def _execute_chunk_v2(self, process, chunk):
951951
metadata, body = chunk

0 commit comments

Comments
 (0)