"""blocking_event_loop -- phase-0-base-project-spec.md ยง7. Owned by `fraud`.""" import hashlib import time from common.chaos_flags import is_enabled _CPU_WORK_SECONDS = 0.15 async def blocking_event_loop_enabled() -> bool: return await is_enabled("blocking_event_loop") def synchronous_cpu_work() -> None: """~120ms of real, synchronous, CPU-bound work run directly inside an `async def` handler -- no run_in_executor/to_thread. This is the point: it blocks the whole event loop, serialising every other in-flight request on this worker for the duration.""" deadline = time.perf_counter() + _CPU_WORK_SECONDS data = b"ledgerline-fraud-scoring" while time.perf_counter() < deadline: data = hashlib.sha256(data).digest()