|
Download fixes/applied_changes_backend.md from SolutionChallenge/solution_challenge_backend: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/SolutionChallenge/solution_challenge_backend/resolve/main/fixes/applied_changes_backend.md
- Command line
-
hf download hf://spaces/SolutionChallenge/solution_challenge_backend/fixes/applied_changes_backend.md
-
curl -L -o applied_changes_backend.md https://huggingface.co/spaces/SolutionChallenge/solution_challenge_backend/resolve/main/fixes/applied_changes_backend.md
1.13 kB
| # Applied Backend Fixes | |
| 1. **WebSocket Concurrency Error Fix**: | |
| - **Location**: `backend/main.py` -> `ConnectionManager.broadcast` and `ConnectionManager.broadcast_to_agents`. | |
| - **Change**: Updated the iterator from `self.active_connections` (and `self.agent_connections`) to `list(self.active_connections)`. | |
| - **Reason**: In an async environment, yielding execution via `await` while iterating a list leaves the list open to modification (e.g., another coroutine closing the socket and removing it). Iterating over a copy prevents iteration issues like missing elements or `RuntimeError`. | |
| 2. **Detections History Memory Leak Fix**: | |
| - **Location**: `backend/main.py` -> `_upsert_detection_sighting`. | |
| - **Change**: Added `_trim_memory_list(detections_history, 500)` immediately after appending a new record to `detections_history`. | |
| - **Reason**: Most history arrays in the project use `_trim_memory_list` to enforce a maximum cap. `detections_history` was appending arbitrarily, representing an unbounded memory leak if there's a constant influx of unique/unknown person detections over prolonged uptime. | |