original_docstring: 
      Polls QRadar service for search ID given until status returned is within 'TERMINATING_SEARCH_STATUSES'.
      Afterwards, performs a call to retrieve the events returned by the search.
      Has retry mechanism, because QRadar service tends to return random errors when
      it is loaded.
      Therefore, 'max_retries' retries will be made, to try avoid such cases as much as possible.
  
      Args:
          client (Client): Client to perform the API calls.
          search_id (str): ID of the search to poll for its status.
          offense_id (int): ID of the offense to enrich with events returned by search. Used for logging purposes here.
          max_retries (int): Number of retries.
  
      Returns:
          (List[Dict]): List of events returned by query. Returns empty list if number of retries exceeded limit.
      
docstring: Polls QRadar service for search ID given until status returned is within 'TERMINATING_SEARCH_STATUSES'.
  Afterwards, performs a call to retrieve the events returned by the search.
  Has retry mechanism, because QRadar service tends to return random errors when
  it is loaded.
  Therefore, 'max_retries' retries will be made, to try avoid such cases as much as possible.
docstring_tokens: Polls QRadar service for search ID given until status returned is within ' TERMINATING_SEARCH_STATUSES ' . Afterwards performs a call to retrieve the events returned by the search . Has retry mechanism because QRadar service tends to return random errors when it is loaded . Therefore ' max_retries ' retries will be made to try avoid such cases as much as possible .
code: def poll_offense_events_with_retry(client: Client, search_id: str, offense_id: int,
                                     max_retries: int = EVENTS_FAILURE_LIMIT) -> List[Dict]:
      """
      Polls QRadar service for search ID given until status returned is within 'TERMINATING_SEARCH_STATUSES'.
      Afterwards, performs a call to retrieve the events returned by the search.
      Has retry mechanism, because QRadar service tends to return random errors when
      it is loaded.
      Therefore, 'max_retries' retries will be made, to try avoid such cases as much as possible.
  
      Args:
          client (Client): Client to perform the API calls.
          search_id (str): ID of the search to poll for its status.
          offense_id (int): ID of the offense to enrich with events returned by search. Used for logging purposes here.
          max_retries (int): Number of retries.
  
      Returns:
          (List[Dict]): List of events returned by query. Returns empty list if number of retries exceeded limit.
      """
      num_of_failures = 0
      start_time = time.time()
      while num_of_failures <= max_retries:
          try:
              if is_reset_triggered():
                  return []
              search_status_response = client.search_status_get(search_id)
              query_status = search_status_response.get('status')
              # failures are relevant only when consecutive
              num_of_failures = 0
              if query_status in TERMINATING_SEARCH_STATUSES:
                  search_results_response = client.search_results_get(search_id)
                  events = search_results_response.get('events', [])
                  sanitized_events = sanitize_outputs(events)
                  print_debug_msg(f'Events fetched for offense {offense_id}.')
                  return sanitized_events
              elapsed = time.time() - start_time
              if elapsed >= FETCH_SLEEP:  # print status debug every fetch sleep (or after)
                  print_debug_msg(f'Still fetching offense {offense_id} events, search_id: {search_id}.')
                  start_time = time.time()
              time.sleep(EVENTS_INTERVAL_SECS)
          except Exception as e:
              print_debug_msg(
                  f'Error while fetching offense {offense_id} events, search_id: {search_id}. Error details: {str(e)}')
              num_of_failures += 1
              if num_of_failures < max_retries:
                  time.sleep(FAILURE_SLEEP)
      return []
code_tokens: def poll_offense_events_with_retry ( client : Client , search_id : str , offense_id : int , max_retries : int = EVENTS_FAILURE_LIMIT ) -> List [ Dict ] : num_of_failures = 0 start_time = time . time ( ) while num_of_failures <= max_retries : try : if is_reset_triggered ( ) : return [ ] search_status_response = client . search_status_get ( search_id ) query_status = search_status_response . get ( 'status' ) num_of_failures = 0 if query_status in TERMINATING_SEARCH_STATUSES : search_results_response = client . search_results_get ( search_id ) events = search_results_response . get ( 'events' , [ ] ) sanitized_events = sanitize_outputs ( events ) print_debug_msg ( f'Events fetched for offense {offense_id}.' ) return sanitized_events elapsed = time . time ( ) - start_time if elapsed >= FETCH_SLEEP : print_debug_msg ( f'Still fetching offense {offense_id} events, search_id: {search_id}.' ) start_time = time . time ( ) time . sleep ( EVENTS_INTERVAL_SECS ) except Exception as e : print_debug_msg ( f'Error while fetching offense {offense_id} events, search_id: {search_id}. Error details: {str(e)}' ) num_of_failures += 1 if num_of_failures < max_retries : time . sleep ( FAILURE_SLEEP ) return [ ]
short_docstring: Polls QRadar service for search ID given until status returned is within 'TERMINATING_SEARCH_STATUSES'.
short_docstring_tokens: Polls QRadar service for search ID given until status returned is within ' TERMINATING_SEARCH_STATUSES ' .
comment: """
      Polls QRadar service for search ID given until status returned is within 'TERMINATING_SEARCH_STATUSES'.
      Afterwards, performs a call to retrieve the events returned by the search.
      Has retry mechanism, because QRadar service tends to return random errors when
      it is loaded.
      Therefore, 'max_retries' retries will be made, to try avoid such cases as much as possible.
  
      Args:
          client (Client): Client to perform the API calls.
          search_id (str): ID of the search to poll for its status.
          offense_id (int): ID of the offense to enrich with events returned by search. Used for logging purposes here.
          max_retries (int): Number of retries.
  
      Returns:
          (List[Dict]): List of events returned by query. Returns empty list if number of retries exceeded limit.
      """$SEP$# failures are relevant only when consecutive$SEP$# print status debug every fetch sleep (or after)