Skip to content

Commit

Permalink
Send stdout to /dev/null unless it is needed (#43)
Browse files Browse the repository at this point in the history
'unrar' produces lots of output to stdout, and previously this
output was stored in a pipe with Subprocess.PIPE, which could get
filled up, causing everything to hang.

Almost all the of the time we do not care what uncompressors are
producing on stdout, so just send it to /dev/null. Add a way of
stopping this behaviour for the one uncompressor which currently
does read the output pipe.
  • Loading branch information
ChrisJefferson authored May 11, 2023
1 parent ca6dbbd commit c69cbe8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dtrx/dtrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,13 @@ def wait_for_exit(self, pipe):
% (self.filename)
)

def send_stdout_to_dev_null(self):
return True

def run_pipes(self, final_stdout=None):
has_output_target = True if final_stdout else False
has_output_target = (
True if final_stdout or self.send_stdout_to_dev_null() else False
)
if not self.pipes:
return
elif final_stdout is None:
Expand Down Expand Up @@ -713,6 +718,9 @@ def get_filenames(self):
yield line[fn_index:]
self.archive.close()

def send_stdout_to_dev_null(self):
return False

def timeout_check(self, pipe):
nbs = NonblockingRead(pipe.stdout)
errs = nbs.readlines()
Expand Down
Binary file added tests/test-lots-files.rar
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@
cd test-1.23
unar -D ../$1 || unrar x ../$1
- name: many files .rar
filenames: test-lots-files.rar
baseline: |
mkdir test-lots-files
cd test-lots-files
unar -D ../$1 || unrar x ../$1
- name: basic .arj
filenames: test-1.23.arj
baseline: |
Expand Down

0 comments on commit c69cbe8

Please sign in to comment.