Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix restore after capture with optimized file pipes #89

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ def test_two_file_pipes(tmpdir):
assert w.thread is None
printf("some stdout")
printf_err("some stderr")
# make sure capture stopped
printf("after stdout")
printf_err("after stderr")

with test_stdout.open() as f:
assert f.read() == "some stdout\n"
Expand Down
2 changes: 1 addition & 1 deletion wurlitzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def _setup_pipe(self, name):
real_fd = getattr(sys, '__%s__' % name).fileno()
save_fd = os.dup(real_fd)
self._save_fds[name] = save_fd
self._real_fds[name] = real_fd

try:
capture_fd = getattr(self, "_" + name).fileno()
Expand All @@ -233,7 +234,6 @@ def _setup_pipe(self, name):

dup2(pipe_in, real_fd)
os.close(pipe_in)
self._real_fds[name] = real_fd

# make pipe_out non-blocking
flags = fcntl(pipe_out, F_GETFL)
Expand Down
Loading