MCPcopy Create free account
hub / github.com/Emmimal/control-layer / test_thread_safe

Method test_thread_safe

tests/test_control_layer.py:280–295  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

278 assert cb.state == CircuitState.HALF_OPEN
279
280 def test_thread_safe(self):
281 cb = CircuitBreaker(failure_threshold=100)
282 errors = []
283
284 def worker():
285 try:
286 for _ in range(20):
287 cb.record_failure()
288 cb.record_success()
289 except Exception as e:
290 errors.append(e)
291
292 threads = [threading.Thread(target=worker) for _ in range(5)]
293 for t in threads: t.start()
294 for t in threads: t.join()
295 assert len(errors) == 0
296
297
298# =============================================================================

Callers

nothing calls this directly

Calls 1

CircuitBreakerClass · 0.90

Tested by

no test coverage detected