Skip to content
Merged
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
11 changes: 9 additions & 2 deletions python/hdfs_native/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# PYTHON_ARGCOMPLETE_OK

import functools
import glob
import os
Expand Down Expand Up @@ -1391,7 +1390,15 @@ def show_help(args: Namespace):

autocomplete(parser)
args = parser.parse_args(in_args)
args.func(args)

# Catch broken pipes in case the output is being piped to a command that exits early
try:
args.func(args)
except BrokenPipeError:
# Python flushes standard streams on exit; redirect remaining output
# to devnull to avoid another BrokenPipeError at shutdown
devnull = os.open(os.devnull, os.O_WRONLY)
os.dup2(devnull, sys.stdout.fileno())


if __name__ == "__main__":
Expand Down
Loading