nerdexam
Cisco

350-901 · Question #30

Refer to the exhibit. The self-service Webex Teams bot is failing when many users attempt to interact with it at the same time. Drag and drop the code snippets from the left onto the correct item…

Based on common retry patterns with exponential backoff and the provided snippets, the most logical mapping for the missing items is: <item 1>: 429 (HTTP status code for Too Many Requests, which typically triggers a retry, so if the status is NOT 429, we might not retry) <item…

Using APIs

Question

Refer to the exhibit. The self-service Webex Teams bot is failing when many users attempt to interact with it at the same time. Drag and drop the code snippets from the left onto the correct item numbers on the right that match the missing sections in the exhibit to complete this code to handle this high-load situation. Code Exhibit:
RETRIES = 6
i = 0
backoff = 1

while True:
 try:
 response = requests.request(*args, **kwargs)
 response.raise_for_status()
 return response
 except Exception as e:
 if (response.status_code != <item 1>) or i == <item 2>:
 return response

 time.sleep(<item 3>)
 <item 4> *= 2
 <item 5> += 1
Available Snippets from Answer Area: 429, i, backoff, backoff, RETRIES

Exhibit

350-901 question #30 exhibit

Explanation

Based on common retry patterns with exponential backoff and the provided snippets, the most logical mapping for the missing items is:

  • <item 1>: 429 (HTTP status code for Too Many Requests, which typically triggers a retry, so if the status is NOT 429, we might not retry)
  • <item 2>: RETRIES (Maximum number of retry attempts)
  • <item 3>: backoff (Current sleep duration for the retry mechanism)
  • <item 4>: backoff (Variable to modify for exponential backoff, e.g., doubling the wait time)
  • <item 5>: i (Retry counter, incremented after each attempt)

Complete code with logical placements:

RETRIES = 6
i = 0
backoff = 1

while True:
    try:
        response = requests.request(*args, **kwargs)
        response.raise_for_status()
        return response
    except Exception as e:
        # Note: Assuming e.response.status_code is accessible from the exception context.
        if (getattr(e.response, 'status_code', None) != 429) or i == RETRIES:
            return response

        time.sleep(backoff)
        backoff *= 2
        i += 1

Topics

#API Error Handling#Rate Limiting#Retry Logic#Exponential Backoff

Community Discussion

No community discussion yet for this question.

Full 350-901 Practice