docs(vector): correct _drive_local_coroutine suspension-guard comment (#926)
The prior comment claimed anyio.lowlevel.checkpoint() yields None and is re-driven, but checkpoint() yields a non-None backend object (asyncio Future / trio checkpoint) and so trips the RuntimeError guard. Clarify that only a literal bare yield/yield None is re-driven; any real awaitable is caught by the non-None guard. Comment-only; no behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
5b468514ec
commit
420c8cd2d3
@@ -126,14 +126,15 @@ def _drive_local_coroutine(coro: Coroutine[Any, Any, Any]) -> Any:
|
|||||||
thread dispatched by :func:`anyio.to_thread.run_sync` — is what moves that
|
thread dispatched by :func:`anyio.to_thread.run_sync` — is what moves that
|
||||||
CPU work off the event loop.
|
CPU work off the event loop.
|
||||||
|
|
||||||
A genuine suspension (a non-``None`` yield) would mean the backend started
|
A genuine suspension would mean the backend started doing real async I/O,
|
||||||
doing real async I/O, which a plain thread cannot drive correctly. Fail
|
which a plain thread cannot drive correctly. Any real awaitable yields a
|
||||||
loudly in that case rather than spin or silently mis-drive the coroutine.
|
non-``None`` object (an asyncio ``Future`` / a trio checkpoint), so the
|
||||||
A bare ``yield None`` (e.g. a hand-inserted ``anyio.lowlevel.checkpoint()``)
|
``yielded is not None`` guard catches it and fails loudly rather than
|
||||||
is deliberately treated as a non-suspension and re-driven — consistent with
|
spinning or silently mis-driving the coroutine. Only a literal bare
|
||||||
the local backend being purely synchronous. If a qdrant adapter ever starts
|
``yield`` / ``yield None`` is treated as a non-suspension and re-driven —
|
||||||
inserting real checkpoints, prefer wrapping it in network mode over relaxing
|
consistent with the local backend being purely synchronous. If a qdrant
|
||||||
this guard.
|
adapter ever starts inserting real checkpoints, prefer wrapping it in
|
||||||
|
network mode over relaxing this guard.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
Reference in New Issue
Block a user