Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Changelog
version 1.0.1-dev
-----------------
+ Update included zlib-ng distribution to 2.3.3.
+ Fix BrokenPipeError when piping ``python -m isal.igzip`` into ``head``,
``less`` or similar programs.
+ Fix ``gzip_ng_threaded`` writers that waited forever when writing to the
underlying file failed, for example, because the disk was full. A later call
to ``write()``, ``flush()``, or ``close()`` raises the error. After an error,
Expand Down
3 changes: 3 additions & 0 deletions src/zlib_ng/gzip_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ def main():
READ_BUFFER_SIZE = args.buffer_size
try:
shutil.copyfileobj(in_file, out_file, args.buffer_size)
except BrokenPipeError:
# Do not throw errors when a pipe to head or less closes.
pass
finally:
if in_file is not sys.stdin.buffer:
in_file.close()
Expand Down
12 changes: 12 additions & 0 deletions tests/test_gzip_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import re
import shutil
import struct
import subprocess
import sys
import tempfile
import zlib
Expand Down Expand Up @@ -496,3 +497,14 @@ def test_adverserial_header():
gzip_file.read()
finally:
os.remove(tmpfile.name)


@pytest.mark.skipif(sys.platform != "linux", reason="bash required")
def test_no_broken_pipe():
subprocess.run(
[
"bash", "-c", "-e", "-o", "pipefail",
f"{sys.executable} -m zlib_ng.gzip_ng -cd {TEST_FILE} | head -n 10"
],
check=True
)
Loading