Skip to content

Commit 36d222f

Browse files
aijShakeel
authored andcommitted
Clean up and match previous behavior more closely
1 parent 9304b0a commit 36d222f

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

splunklib/searchcommands/generating_command.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ def generate(self):
193193
"""
194194
raise NotImplementedError('GeneratingCommand.generate(self)')
195195

196-
197-
198196
def _execute(self, ifile, process):
199197
""" Execution loop
200198

splunklib/searchcommands/internals.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,6 @@ def _clear(self):
556556
self._buffer.truncate()
557557
self._inspector.clear()
558558
self._record_count = 0
559-
self._flushed = False
560559

561560
def _ensure_validity(self):
562561
if self._finished is True:
@@ -654,7 +653,6 @@ def _write_record(self, record):
654653
self._record_count += 1
655654

656655
if self._record_count >= self._maxresultrows:
657-
658656
self.flush(partial=True)
659657

660658
try:
@@ -755,8 +753,8 @@ def flush(self, finished=None, partial=None):
755753
# provide a way to send partial chunks yet.
756754
return
757755

758-
#if finished is True:
759-
self.write_chunk(finished=True)
756+
if not self.is_flushed:
757+
self.write_chunk(finished=True)
760758

761759
def write_chunk(self, finished=None):
762760
inspector = self._inspector
@@ -821,4 +819,4 @@ def _write_chunk(self, metadata, body):
821819
self.write(metadata)
822820
self.write(body)
823821
self._ofile.flush()
824-
self._flushed = False
822+
self._flushed = True

splunklib/searchcommands/search_command.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,8 @@ def _execute_v2(self, ifile, process):
941941
action = getattr(metadata, 'action', None)
942942
if action != 'execute':
943943
raise RuntimeError('Expected execute action, not {}'.format(action))
944+
945+
self._finished = getattr(metadata, 'finished', False)
944946
self._record_writer.is_flushed = False
945947

946948
self._execute_chunk_v2(process, result)

0 commit comments

Comments
 (0)