Skip to content

Commit 9304b0a

Browse files
aijShakeel
authored andcommitted
Fix generating commands
1 parent 3ff09d9 commit 9304b0a

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
@@ -194,14 +194,6 @@ def generate(self):
194194
raise NotImplementedError('GeneratingCommand.generate(self)')
195195

196196

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

206198
def _execute(self, ifile, process):
207199
""" Execution loop
@@ -213,12 +205,22 @@ def _execute(self, ifile, process):
213205
214206
"""
215207
if self._protocol_version == 2:
216-
self._execute_v2(ifile, self.__generate_chunk)
208+
self._execute_v2(ifile, self.generate())
217209
else:
218210
assert self._protocol_version == 1
219211
self._record_writer.write_records(self.generate())
220212
self.finish()
221213

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

224226
# 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)