-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Great package, thanks!
I noticed the CLI tool gives traceback info when it encounters a broken pipe, which seems unnecessary. E.g.
python -m zlib_ng.gzip_ng -c -d FILE.gz | head -1
will produce a traceback like:
Traceback (most recent call last):
File "/opt/conda/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/conda/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/opt/conda/lib/python3.10/site-packages/zlib_ng/gzip_ng.py", line 317, in <module>
main()
File "/opt/conda/lib/python3.10/site-packages/zlib_ng/gzip_ng.py", line 306, in main
shutil.copyfileobj(in_file, out_file, args.buffer_size)
File "/opt/conda/lib/python3.10/shutil.py", line 198, in copyfileobj
fdst_write(buf)
BrokenPipeError: [Errno 32] Broken pipe
whereas gzip -c -d FILE.gz | head -n 1
would halt without any extra lines. Having the traceback isn't really a problem, but I've suppressed things like this before e.g.
try:
run_stuff(*args)
except (KeyboardInterrupt, BrokenPipeError):
devnull = os.open(os.devnull, os.O_WRONLY)
os.dup2(devnull, sys.stdout.fileno())
sys.exit(0)
Metadata
Metadata
Assignees
Labels
No labels