forked from cardosofelipe/fast-next-template
fix(memory): add thread-safe singleton initialization
- Add threading.Lock with double-check locking to ScopeManager - Add asyncio.Lock with double-check locking to MemoryReflection - Make reset_memory_metrics async with proper locking - Update test fixtures to handle async reset functions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -499,10 +499,11 @@ async def get_memory_metrics() -> MemoryMetrics:
|
||||
return _metrics
|
||||
|
||||
|
||||
def reset_memory_metrics() -> None:
|
||||
async def reset_memory_metrics() -> None:
|
||||
"""Reset the singleton instance (for testing)."""
|
||||
global _metrics
|
||||
_metrics = None
|
||||
async with _lock:
|
||||
_metrics = None
|
||||
|
||||
|
||||
# Convenience functions
|
||||
|
||||
Reference in New Issue
Block a user