@app.after_request
def update_data(response):
try:
if not redis.get('fresh'):
redis.setex('fresh', 'yes', 60)
run_expensive_update_operation()
except ConnectionError as e:
if app.debug:
run_expensive_update_operation()
return response