[BUG] `@coco.fn(batching=True)` / `@coco.fn(runner=...)` 都拒绝异步和同步函数;文档中记录的异步形式无法使用
作者: hardness1020创建于 2026年9月13日更新于 2026年9月13日
Describe the bug
- With
batching=True,runner=..., ormax_batch_size=...,@coco.fnpicks_SyncFunctionBuilder. - That builder rejects
async def("use@coco.fn.as_async"). For syncdef,_build_syncrejects batching / runner ("must be async"). No input passes. - Docs, docstring, and types all say the async form works:
docs/src/content/docs/programming_guide/function.mdx:293: "If the underlying function is alreadyasync def,@coco.fn(batching=True)works directly."function.mdx:325: example@coco.fn(batching=True, max_batch_size=64)onasync def embed(...). Raises at import when copied verbatim.function.mdx:357: same claim for runner: "If the underlying function is alreadyasync def,@coco.fn(runner=...)works directly."_AsyncBatchedDecorator(function.py:114-138) and the overload at:1969-1981. mypy types the docs example asAsyncFunction[[str], list[float]], then runtime raises.
- Side effect:
@coco.fn(max_batch_size=32)on syncdefbuilds a plainSyncFunctionand silently drops the option; onasync defit raises the misleading "Async functions are not supported" message. - All in-repo callers use
@coco.fn.as_async(...)(ops/sentence_transformers.py,ops/litellm.py,tests/core/test_function_batching.py), so CI never hits it. Users following the docs do.
内容来源: cocoindex-io/cocoindex