Add tee-fd capture mode and capteefd fixtures#14432
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… into tee-fd-capture
RonnyPfannschmidt
left a comment
There was a problem hiding this comment.
This looks good to me
This will also need mitigation in xdist
The details that is a pain is the introduction of threads
threads
This is the first active use of threads in pytest
I do also wonder if modern syscalls like sendfile could be used for leaving most of the work to the kernel as i do have a number of unfortunate interactions with select loops
|
Thanks! I poked at sendfile/splice. The terminal-passthrough side could use splice on Linux to save a memcpy, but the capture side has to land in a Python bytes object for readouterr(), and the kernel calls can't do that - they only move pages between fds. So a userspace reader stays no matter what. Net effect would be a Linux-only optimisation on one half, not removing the thread. I can consolidate the two reader threads (one per fd) into a single one for the whole MultiCapture session if that helps. Let me know. Will open an xdist follow-up after this merges. |
Summary
This PR implements
--capture=tee-fdmode andcapteefd/capteefdbinaryfixtures, addressing issue #14159.The new capture mode enables FD-level capture (including subprocess output) while simultaneously passing output through to the terminal in real-time.
closes #14159
Changes
--capture=tee-fdCLI optioncapteefdandcapteefdbinaryfixturesFDCaptureTeeandFDCaptureBinaryTeeclasses using pipe+thread architectureselect) and Windows (using queue-based approach)Test Plan
pytest testing/test_capture.py::TestFDCaptureTee- 11 tests passpytest testing/test_capture.py::TestCaptureFixture::test_capteefd- fixture tests pass