mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-05 08:06:15 +00:00
* 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
17 lines
511 B
Python
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
|