fix: isolate per-execution log buffers for parallel eval runs#102
Open
smflorentino wants to merge 3 commits intomainfrom
Open
fix: isolate per-execution log buffers for parallel eval runs#102smflorentino wants to merge 3 commits intomainfrom
smflorentino wants to merge 3 commits intomainfrom
Conversation
When UIPATH_JOB_KEY is set and eval runs execute in parallel, two bugs caused jumbled and truncated log output in the execution log file: 1. **Interleaved output**: Each child interceptor replaced the global sys.stdout/sys.stderr with a new LoggerWriter, stomping the previous one. All concurrent async tasks wrote to the last-installed writer's single shared buffer, merging partial lines from different executions. 2. **Truncated output**: LoggerWriter.buffer was never flushed before teardown. Partial lines (without a trailing newline) were silently discarded when the handler was closed. Fix: - LoggerWriter now maintains per-context buffers keyed by current_execution_id, so concurrent tasks never share a buffer. - Child interceptors no longer replace sys.stdout/sys.stderr — only the master interceptor owns the global streams. Children register their handler on the stdout/stderr loggers; the existing filter system routes records to the correct handler. - Teardown flushes buffers before clearing context and removing handlers, so partial lines are never lost. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
chore: regenerate uv.lock after version bump to 0.10.1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c1895a9 to
8987807
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two bugs that caused jumbled and truncated log output when
UIPATH_JOB_KEYis set and eval runs execute in parallel.Bug 1: Interleaved output
When eval runs N items in parallel, each item creates a child
UiPathRuntimeLogsInterceptorviaUiPathExecutionRuntime.execute(). The old code called_redirect_stdout_stderr()in child mode, which did:sys.stdoutis a single global. Each child overwrites it with a newLoggerWriterinstance. If 4 eval items run concurrently:sys.stdouttoLoggerWriter_1sys.stdouttoLoggerWriter_2(LoggerWriter_1is now orphaned)sys.stdouttoLoggerWriter_3(LoggerWriter_2is now orphaned)sys.stdouttoLoggerWriter_4(LoggerWriter_3is now orphaned)All 4 tasks call
print(), which writes tosys.stdout— but that'sLoggerWriter_4. One buffer, four writers. Lines merge. When earlier children tear down and restoresys.stdout, the later children'sLoggerWriterinstances are orphaned along with any buffered content.Bug 2: Truncated output
LoggerWriter.bufferwas never flushed before teardown. Partial lines (no trailing\n) were silently discarded when the handler was closed.Changes
LoggerWriternow maintains per-context buffers keyed bycurrent_execution_id— concurrent tasks never share a buffersys.stdout/sys.stderr— only the master owns global streams. Children register their handler on the stdout/stderr loggers; the existing filter system routes records correctly.Test plan
logging.info()+print()— verified zero cross-contamination🤖 Generated with Claude Code