OllamaModelBackend: use TaskGroup for structured cancellation in generate_from_raw
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 50/100
Línea de trabajo
Start in OllamaModelBackend.generate_from_raw, where the asyncio.gather call from PR #1163 runs the parallel Ollama requests. The issue proposes replacing it with an asyncio.TaskGroup so that one failure cancels the remaining requests. Decide how callers that catch ConnectionError will handle the ExceptionGroup, then confirm that a failed request cancels the others.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Background
PR #1163 fixed generate_from_raw to propagate exceptions instead of silently swallowing them into empty ModelOutputThunk(value="") (issue #597). The fix uses asyncio.gather(*coroutines) (default return_exceptions=False).
Problem
With asyncio.gather(return_exceptions=False), when one coroutine raises, the other in-flight coroutines are not cancelled — they continue running on the event loop until completion, but their results are discarded. For N parallel Ollama HTTP requests, this means up to N−1 requests complete and their results are thrown away.
This is a pre-existing behaviour of asyncio.gather made visible by the fix in #1163. It was not introduced by that PR; under the old code all N tasks always ran to completion (whether they failed or not).
Desired behaviour
Python 3.12 (the project's minimum version) has asyncio.TaskGroup, which provides structured concurrency: if any task in the group raises, the remaining tasks are cancelled. This avoids wasted compute and network bandwidth.
async with asyncio.TaskGroup() as tg:
tasks = [tg.create_task(co) for co in coroutines]
responses = [t.result() for t in tasks]
Caveats
TaskGroupraisesExceptionGroup(not the raw exception) on failure. Callers that doexcept ConnectionErrorwould need to useexcept*orExceptionGrouphandling. This is a semantic change on top of the change in #1163.- Consider whether to unwrap single-exception groups to preserve the plain-exception API surface.
Related
- Closes #597 (via #1163)
- PR #1163 — introduced
gatherwithoutreturn_exceptions
- Lenguaje dominante
- Python
- Estrellas
- 1.8k
- Forks
- 161
- Merge medio
- 4 d 3 h
- PR fusionados (30 d)
- 45
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de generative-computing/mellea
-
bug: `mellea.plugins.builtin_debug.generation.log_generation_post_call` shows model as unknownAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
generative-computing/mellea#1864 ·
Los mantenedores suelen responder en 3 días
-
bug: instruct() and react() replay tool-call turns without tool_callsPosiblemente ocupada @simonyang08 la tomó hace 21 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
generative-computing/mellea#1784 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
Silently mangled docstrings: lone backslash line-continuations in non-raw docstrings collapse command examplesPosiblemente ocupada @madhusudhan1260 la tomó hace 18 días. Abiertogood first issue p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
generative-computing/mellea#1780 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
area/telemetry enhancement p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
generative-computing/mellea#1210 ·
Los mantenedores suelen responder en 3 días
-
Add requirement priorityAbiertoarea/requirement area/stdlib enhancement p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
generative-computing/mellea#31 · 2 comentarios ·
Los mantenedores suelen responder en 3 días
Todos los issues de generative-computing/mellea
Issues similares
-
cron: raise a distinct error when next_fire finds no match in its search bound (from #813 item 5)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Pin Hugging Face commit revisions for AuK weight downloads and eliminate post-download SHA TOCTOUAbiertoarea:voice better-dependency-freedom dependencies effort:low in-progress model:medium plan planner:gemini-4-neon-high priority:2 security
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
needs-area-label
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
OpenFreeEnergy/openfe#2371 ·
Los mantenedores suelen responder en 2 días
-
HMDB's smiles file writes "None" for metabolites with an empty <smiles/> (file not currently used)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
NCATSTranslator/Babel#1269 ·
Los mantenedores suelen responder en 1 día