Mark async socket handling task done and implement startup cleanup

This commit is contained in:
2026-04-09 22:13:22 +02:00
parent 148756fb79
commit 6b177f1881
5 changed files with 99 additions and 66 deletions

View File

@@ -56,6 +56,7 @@ Reference: `Docs/Refactoring.md` for full analysis of each issue.
### 6. Update async socket handling
- Where found: `backend/app/utils/fail2ban_client.py`, `backend/app/startup.py`
- Goal: use modern asyncio APIs (`get_running_loop()`), avoid blocking operations on the event loop, and ensure startup resources are cleaned up if initialization fails.
- Status: completed — switched fail2ban socket I/O to `asyncio.to_thread` and added startup cleanup for failed resource initialization.
- Possible traps and issues:
- `asyncio.get_event_loop()` behavior changed in newer Python versions; this can cause runtime warnings or errors.
- Resource leaks can occur if `startup_shared_resources()` fails before the lifespan shutdown path is reached.