Skip to content

Forward task output to the log while the command runs - #20

Closed
jhidding wants to merge 5 commits into
msgspec-constructfrom
live-task-output
Closed

jhidding wants to merge 5 commits into
msgspec-constructfrom
live-task-output

Conversation

@jhidding

Copy link
Copy Markdown
Contributor

Stacked on #19; merge that one (and #18) first.

Until now, stderr of a task was only logged after the command finished (proc.communicate()), and stdout that wasn't redirected went straight to the terminal, bypassing the logger.

_exec now reads stderr, and stdout when it doesn't go to a file or variable, line by line while the command runs, and logs each line with the task's note. stdin from a variable is written to the process directly.

Output lines are now escaped before logging. With Rich markup enabled, command output containing brackets like [/foo] used to raise a MarkupError.

Things to be aware of:

  • Commands now write stdout to a pipe instead of the terminal, so some tools turn off colours or progress bars.
  • A single output line longer than 64 KiB (the default StreamReader limit) raises an error. This can be raised with limit= if needed.
  • Output of parallel tasks is now interleaved line by line, each line tagged with its task.

🤖 Generated with Claude Code

jhidding and others added 5 commits November 16, 2026 08:23
The one-liner and runner code paths in `Task.run` duplicated process
creation, throttling, stderr logging and return-code checking. Both now
produce a list of commands (`get_commands`) that is run by `_exec`.
Standard input is handled by a `get_stdin` context manager, which also
closes the input file after use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each `Lazy` task now stores the `asyncio.Future` that computes it, so
concurrent requests await the same future. This replaces the per-task
lock, the cached `Result`, and `run_cached`/`run_after_deps`. Inside the
DB, failures propagate as exceptions; `LazyDB.run` still returns `Ok` or
a `Failure`, so its interface is unchanged.

Cycle detection now checks which tasks are waiting on which, instead of
following the path of a single request. The old check missed a cycle
reached from two branches at once (`all` needing both `a` and `b`, with
`a` and `b` needing each other), which deadlocked; there is a test for
this case now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`Template` only added a `call` method that substituted its arguments.
Templates are now plain `TaskProxy` objects, and `tasks_from_call`
calls `substitute` directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`_exec` used `proc.communicate()`, so stderr was only logged after the
command finished, and uncaptured stdout went straight to the terminal,
bypassing the logger. Now stderr, and stdout when it isn't redirected to
a file or variable, are read line by line and logged as they arrive.

Output lines are escaped before logging with Rich markup enabled, so
command output containing brackets like `[/foo]` no longer raises a
`MarkupError`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from simplify-tasks to msgspec-construct November 16, 2026 11:17
@jhidding jhidding closed this Nov 16, 2026
@jhidding
jhidding deleted the live-task-output branch November 16, 2026 18:55

This branch was previously deployed

1 inactive deployment
github-pages — f414daed Deployed Nov 16, 2026 by jhidding via deploy #29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant