Skip to content

Commit 987e6bc

Browse files
fix: changes repeat_search_until method to return last search state as it should according to inline docs
1 parent f5fc5eb commit 987e6bc

File tree

1 file changed

+11
-3
lines changed
  • splunk_add_on_ucc_modinput_test/functional/splunk

1 file changed

+11
-3
lines changed

splunk_add_on_ucc_modinput_test/functional/splunk/client.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,17 @@ def repeat_search_until(
263263
@return: SearchState object.
264264
"""
265265

266+
last_state: SearchState | None = None
267+
def internal_condition_fn(state: SearchState) -> bool:
268+
nonlocal last_state
269+
last_state = state
270+
if callable(condition_fn):
271+
return condition_fn(state)
272+
return state.result_count > 0
273+
266274
it = self.search_probe(
267275
probe_spl=spl,
268-
verify_fn=condition_fn,
276+
verify_fn=internal_condition_fn,
269277
timeout=timeout,
270278
interval=interval,
271279
probe_name=None,
@@ -275,5 +283,5 @@ def repeat_search_until(
275283
while True:
276284
wait = next(it)
277285
time.sleep(wait)
278-
except StopIteration as si:
279-
return si.value
286+
except StopIteration:
287+
return last_state

0 commit comments

Comments
 (0)