Skip to content

Commit

Permalink
Add max retry parameter to the execution (#802)
Browse files Browse the repository at this point in the history
Co-authored-by: Meroujan.Antonyan <[email protected]>
Co-authored-by: Ian Hellen <[email protected]>
  • Loading branch information
3 people authored Oct 21, 2024
1 parent 11ca944 commit deab7a5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion msticpy/data/drivers/cybereason_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def __execute_query(
page: int = 0,
page_size: int = 2000,
pagination_token: str = None,
max_retry: int = 3,
) -> Dict[str, Any]:
"""
Run query with pagination enabled.
Expand Down Expand Up @@ -436,7 +437,8 @@ def __execute_query(
headers = {}
params = {"page": page, "itemsPerPage": page_size}
status = None
while status != "SUCCESS":
cur_try = 0
while status != "SUCCESS" and cur_try < max_retry:
response = self.client.post(
self.search_endpoint,
json={**body, **pagination},
Expand All @@ -446,6 +448,7 @@ def __execute_query(
response.raise_for_status()
json_result = response.json()
status = json_result["status"]
cur_try += 1
return json_result

async def __run_threaded_queries(
Expand Down

0 comments on commit deab7a5

Please sign in to comment.