Fix: non-blocking vault sync on startup
This commit is contained in:
parent
e3ad63b01f
commit
3b9d54231b
1 changed files with 4 additions and 3 deletions
5
app.py
5
app.py
|
|
@ -91,9 +91,10 @@ async def _periodic_vault_sync():
|
|||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# Startup: sync vault, fall back to disk cache
|
||||
if not _sync_vault():
|
||||
# Startup: try vault sync in background, use file fallback immediately
|
||||
_load_disk_cache()
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_in_executor(None, _sync_vault) # non-blocking
|
||||
task = asyncio.create_task(_periodic_vault_sync())
|
||||
yield
|
||||
task.cancel()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue