Skip to content

Commit af8a22c

Browse files
committed
fix: Handle missing save_to_disk method in PostgreSQL backend
- Add hasattr check before calling save_to_disk - This method only exists in mock storage, not PostgreSQL - Fixes AttributeError spam in logs
1 parent f51933b commit af8a22c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app/factory.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,18 @@ async def lifespan(app: FastAPI):
122122

123123

124124
async def periodic_persistence(memory_service, interval: int = 30) -> None:
125-
"""Periodically persist memories to disk"""
125+
"""Periodically persist memories to disk (only for mock storage)"""
126126
while True:
127127
try:
128128
await asyncio.sleep(interval)
129-
await memory_service.save_to_disk()
130-
logger.debug("💾 Periodic persistence checkpoint")
129+
# Only save to disk if using mock storage
130+
if hasattr(memory_service, 'save_to_disk'):
131+
await memory_service.save_to_disk()
132+
logger.debug("💾 Periodic persistence checkpoint")
131133
except asyncio.CancelledError:
132134
# Final save before exit
133-
await memory_service.save_to_disk()
135+
if hasattr(memory_service, 'save_to_disk'):
136+
await memory_service.save_to_disk()
134137
raise
135138
except Exception as e:
136139
logger.exception(f"Persistence error: {e}")

0 commit comments

Comments
 (0)