Skip to content

Commit 3fbc77c

Browse files
committed
Tighten start_or_cancel's startup-RTE match
The `'started' in rte.args[0]` check was too loose: it matched a child task's OWN `RuntimeError(...started...)` (not just trio's "child exited without calling task_status.started()"), and would `TypeError` on a non-`str` `args[0]`. Guard with `isinstance(..., str)` and match trio's exact wording so a real child error can't be demoted to `Cancelled` under cancellation. Review: PR #464 (copilot-pull-request-reviewer) #464 (review) (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
1 parent a722d53 commit 3fbc77c

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

tractor/trionics/_taskc.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,16 @@ async def start_or_cancel(
340340
if (
341341
rte.args
342342
and
343-
'started' in rte.args[0]
343+
isinstance(rte.args[0], str)
344+
and
345+
# match trio's *exact* "child exited without calling
346+
# task_status.started()" wording — a bare `'started'`
347+
# substring would also match a child task's OWN
348+
# `RuntimeError(...started...)` and (under cancellation)
349+
# demote it to a `Cancelled`, losing the real error. The
350+
# `isinstance` guard also avoids a `TypeError` when
351+
# `rte.args[0]` isn't a `str`.
352+
'child exited without calling' in rte.args[0]
344353
):
345354
# re-raises the in-flight `trio.Cancelled` IFF we're
346355
# under effective cancellation; else a cheap no-op and

0 commit comments

Comments
 (0)