Skip to content

Commit d0d3dd5

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

File tree

1 file changed

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

1 file changed

+12
-3
lines changed

splunk_add_on_ucc_modinput_test/functional/splunk/client.py

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

266+
last_state: SearchState | None = None
267+
268+
def internal_condition_fn(state: SearchState) -> bool:
269+
nonlocal last_state
270+
last_state = state
271+
if callable(condition_fn):
272+
return condition_fn(state)
273+
return state.result_count > 0
274+
266275
it = self.search_probe(
267276
probe_spl=spl,
268-
verify_fn=condition_fn,
277+
verify_fn=internal_condition_fn,
269278
timeout=timeout,
270279
interval=interval,
271280
probe_name=None,
@@ -275,5 +284,5 @@ def repeat_search_until(
275284
while True:
276285
wait = next(it)
277286
time.sleep(wait)
278-
except StopIteration as si:
279-
return si.value
287+
except StopIteration:
288+
return last_state

0 commit comments

Comments
 (0)