Skip to content

Commit

Permalink
Few fix splunk driver (#688)
Browse files Browse the repository at this point in the history
* fix splunk driver: remove **kargs argument from _exec_async_search()

* fix splunk driver: pass timeout option to _exec_async_search()

* Black formatting for splunk_driver.py

---------

Co-authored-by: Ian Hellen <ianhelle@microsoft.com>
  • Loading branch information
Tatsuya-hasegawa and ianhelle committed Aug 8, 2023
1 parent 87b5a2c commit 08c89f4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions msticpy/data/drivers/splunk_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ def query(
# Get sets of N results at a time, N=100 by default
page_size = kwargs.pop("page_size", 100)

# default to 60s unless timeout is specified
timeout = kwargs.pop("timeout", 60)

# Normal (non-blocking) searches or oneshot (blocking) searches.
# Defaults to Normal(non-blocking)

Expand All @@ -255,7 +258,9 @@ def query(
query_job = self.service.jobs.create(
query, count=count, **kwargs_normalsearch
)
resp_rows, reader = self._exec_async_search(query_job, page_size, **kwargs)
resp_rows, reader = self._exec_async_search(
query_job, page_size, timeout=timeout
)

if len(resp_rows) == 0 or not resp_rows:
print("Warning - query did not return any results.")
Expand Down Expand Up @@ -333,7 +338,7 @@ def driver_queries(self) -> Iterable[Dict[str, Any]]:
]
return []

def _exec_async_search(self, query_job, page_size, timeout=60):
def _exec_async_search(self, query_job, page_size, timeout):
"""Execute an async search and return results."""
# Initiate progress bar and start while loop, waiting for async query to complete
progress_bar = tqdm(total=100, desc="Waiting Splunk job to complete")
Expand Down

0 comments on commit 08c89f4

Please sign in to comment.