Skip to content

Commit

Permalink
fix restore after capture with optimized file pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Jun 12, 2024
1 parent 0be57d9 commit 36522b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
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

0 comments on commit 36522b8

Please sign in to comment.