INNER CODE UNIT · Python

is_tripped

gravitational/workshop · prod/cbreaker/cbreaker.py:22

def is_tripped():
    global circuit_tripped_until    
    mutex.acquire()
    try:
        return datetime.now() < circuit_tripped_until
    finally:
        mutex.release()
    

@app.route("/")
def hello():
    weather = "weather unavailable"
    try:
        if is_tripped():
            return "circuit breaker: service unavailable (tripped)"

        r = requests.get('http://localhost:5000', timeout=1)
        app.logger.info("requesting weather...")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…