ReMe/reme/utils/async_utils.py
jinliyl fc4a5398a8
fix(index): make embedding rebuild explicit and scoped (#508)
* fix(index): make embedding rebuild explicit and scoped

* fix(index): harden scoped reindex completion

* fix(index): guard embedding space transitions

* fix(index): serialize reindex with mutations

* docs(index): clarify scoped reindex semantics

* docs(index): explain synchronous checkpoint snapshots

* fix(index): serialize checkpoint publication
2026-08-28 23:25:17 +08:00

17 lines
511 B
Python

"""Small asyncio helpers."""
import asyncio
from collections.abc import Callable
from contextlib import suppress
from typing import Any
async def complete_in_thread(func: Callable[..., Any], /, *args) -> Any:
"""Finish a side-effecting thread call before propagating cancellation."""
task = asyncio.create_task(asyncio.to_thread(func, *args))
try:
return await asyncio.shield(task)
except asyncio.CancelledError:
with suppress(Exception):
await task
raise