KaifAhmad1
|
5e23007658
|
fix: use RLock in ResourceScheduler to prevent deadlock
- Change threading.Lock() to threading.RLock() in ResourceScheduler.__init__
- Fixes deadlock in allocate_resources() when it calls allocate_cpu/memory/gpu
- Each allocate_* method also acquires the same lock, causing re-entrancy issue
- RLock allows same thread to re-enter lock without blocking itself
- Resolves build_knowledge_base() hanging indefinitely
Test fixes and improvements:
- Add allocation validation to prevent silent failures
- Move progress tracking updates outside lock for better performance
- Add comprehensive regression tests
- Add explanatory comment for RLock usage
Addresses Qodo review concerns:
✅ Silent allocation failure - now raises ValidationError
✅ Lock held during progress updates - moved outside lock
✅ Deadlock prevention - RLock allows re-entrant acquisition
Resolves: #299
|
2026-02-10 12:22:16 +05:30 |
|