Use this file to discover all available pages before exploring further.
Circuit breakers prevent cascading failures by stopping calls to a failing service. When too many calls fail, the circuit “opens” and blocks further calls until the service recovers.
from splinter.control import CircuitBreaker, CircuitBreakerConfigbreaker = CircuitBreaker( breaker_id="openai", config=CircuitBreakerConfig( failure_threshold=5, # Open after 5 failures timeout_seconds=60, # Stay open for 60s half_open_max=1, # Allow 1 test request ))# Use the breakertry: breaker.check() # Raises if circuit is open result = await call_openai() breaker.record_success()except OpenAIError: breaker.record_failure()except CircuitOpenError: print("Circuit is open, skipping call")
# Something is very wrong - stop all callsregistry.trip_all("Emergency: API returning bad data")# All circuits are now OPEN# No calls will go through# Later, reset when issue is resolvedregistry.reset_all()