Skip to content

fix: handle BrokenPipeError in LMHandler during parallel execution#86

Merged
alexzhang13 merged 2 commits intomainfrom
fix/broken-pipe-parallel-execution
Feb 4, 2026
Merged

fix: handle BrokenPipeError in LMHandler during parallel execution#86
alexzhang13 merged 2 commits intomainfrom
fix/broken-pipe-parallel-execution

Conversation

@alexzhang13
Copy link
Owner

Summary

  • Fix BrokenPipeError that occurred during parallel evaluation runs (e.g., --parallel 9)
  • Add _safe_send() helper method that catches connection errors gracefully
  • Handle connection errors separately from other exceptions to prevent cascading failures

Problem

When running parallel evaluations with the RLM eval harness:

python use_cases/example_workflows/eval_harness.py rlm_oolong ... --parallel 9

Multiple workers connect to the LMHandler socket server simultaneously. When workers complete and close their sockets (or the connection is interrupted), the server would raise BrokenPipeError when trying to send responses. The error handler would then try to send an error response on the same broken socket, causing another BrokenPipeError.

Solution

  1. Added a _safe_send() helper that wraps socket_send() and catches connection errors
  2. Handle BrokenPipeError, ConnectionError, ConnectionResetError, and OSError separately - these are expected during parallel execution and can be silently ignored
  3. Use _safe_send() for all socket operations in the handle() method

Test plan

  • Verified module imports correctly
  • RLM test suite passes (143 tests)
  • Manual test with --parallel 9 to confirm BrokenPipeError is no longer logged

🤖 Generated with Claude Code

alexzhang13 and others added 2 commits February 4, 2026 15:28
When running parallel evaluations, multiple workers connect to the LMHandler
socket server. When workers complete and close their sockets, BrokenPipeError
was raised during response transmission, causing noisy error output.

Changes:
- Add _safe_send() helper that catches connection errors silently
- Handle BrokenPipeError, ConnectionError, ConnectionResetError, and OSError
  separately from other exceptions
- Use _safe_send() for all socket_send() calls in handle() method

This prevents cascading errors where the exception handler tried to send
an error response on an already-broken socket.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@alexzhang13 alexzhang13 merged commit 7436fcf into main Feb 4, 2026
3 checks passed
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