Spaces:
Sleeping
Sleeping
Claude Code Claude Opus 4.6 commited on
Commit ·
775a014
1
Parent(s): a878b29
fix: Avoid deadlock in CircuitBreaker.get_state() by checking can_attempt() before lock
Browse files
app.py
CHANGED
|
@@ -214,12 +214,14 @@ class CircuitBreaker:
|
|
| 214 |
|
| 215 |
def get_state(self) -> Dict[str, Any]:
|
| 216 |
"""Get circuit breaker state."""
|
|
|
|
|
|
|
| 217 |
with self._lock:
|
| 218 |
return {
|
| 219 |
"state": self._state,
|
| 220 |
"failure_count": self._failure_count,
|
| 221 |
"last_failure_time": self._last_failure_time,
|
| 222 |
-
"can_attempt":
|
| 223 |
}
|
| 224 |
|
| 225 |
|
|
|
|
| 214 |
|
| 215 |
def get_state(self) -> Dict[str, Any]:
|
| 216 |
"""Get circuit breaker state."""
|
| 217 |
+
# Check can_attempt BEFORE acquiring lock to avoid deadlock
|
| 218 |
+
can_att = self.can_attempt()
|
| 219 |
with self._lock:
|
| 220 |
return {
|
| 221 |
"state": self._state,
|
| 222 |
"failure_count": self._failure_count,
|
| 223 |
"last_failure_time": self._last_failure_time,
|
| 224 |
+
"can_attempt": can_att
|
| 225 |
}
|
| 226 |
|
| 227 |
|