schedr.first_of

schedr.first_of(a: A, b: B, /, *, with_winner: Literal[False] = False, task_id: str | None = None) → A | B
schedr.first_of(a: A, b: B, /, *, with_winner: Literal[True], task_id: str | None = None) → tuple[A | B, str]
schedr.first_of(a: A, b: B, c: C, /, *, with_winner: Literal[False] = False, task_id: str | None = None) → A | B | C
schedr.first_of(a: A, b: B, c: C, /, *, with_winner: Literal[True], task_id: str | None = None) → tuple[A | B | C, str]
schedr.first_of(*options: T, with_winner: Literal[False] = False, task_id: str | None = None) → T
schedr.first_of(*options: T, with_winner: Literal[True], task_id: str | None = None) → tuple[T, str]

A node that ends as soon as one of these tasks has succeeded, with its value.

publish(first_of(a, b)) passes the first value on; value, winner = first_of(a, b, with_winner=True) also gives the winner’s task ID. Narrow a task with .on(...) to say which of its outcomes count. A task that was skipped doesn’t count, so this also joins the paths of a @branch.

The others aren’t cancelled: they run on as any task, and one failing later fails the run, not this node or what follows it. It is skipped when none of them is taken, and upstream_failed when one failed and none can still succeed.

Parameters:
  • *options (object) – The tasks’ outputs, at least two.

  • with_winner (bool) – Also give the ID of the task that came first.

  • task_id (str | None) – The node’s ID; first_of, numbered from the second on, if not given.

Returns:

The value as a reference to pass to a task, or (value, winner).

Return type:

object