Complete the code to define the state when the circuit breaker allows requests.
state = "[1]" # State when requests are allowed
The Closed state means the circuit breaker allows requests to pass through normally.
Complete the code to specify the state when the circuit breaker blocks requests.
if failure_count > threshold: state = "[1]" # Block requests
The Open state means the circuit breaker blocks requests to prevent further failures.
Fix the error in the code to transition the circuit breaker to the state that tests if the system has recovered.
if timeout_expired: state = "[1]" # Test system recovery
The Half-Open state allows a limited number of requests to test if the system has recovered.
Fill both blanks to complete the request handling logic in the circuit breaker.
if state == "[1]": allow_request = True elif state == "[2]": allow_request = False
Requests are allowed in Closed state and blocked in Open state.
Fill all three blanks to complete the dictionary representing circuit breaker states and their descriptions.
states = {
"Closed": "[1]",
"Open": "[2]",
"Half-Open": "[3]"
}The Closed state means requests are allowed, Open means requests are blocked, and Half-Open means testing limited requests.
