We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2fea467 commit 89fd9f3Copy full SHA for 89fd9f3
python/hdfs_native/cli.py
@@ -1,5 +1,4 @@
1
# PYTHON_ARGCOMPLETE_OK
2
-
3
import functools
4
import glob
5
import os
@@ -1391,7 +1390,15 @@ def show_help(args: Namespace):
1391
1390
1392
autocomplete(parser)
1393
args = parser.parse_args(in_args)
1394
- args.func(args)
+
+ # Catch broken pipes in case the output is being piped to a command that exits early
1395
+ try:
1396
+ args.func(args)
1397
+ except BrokenPipeError:
1398
+ # Python flushes standard streams on exit; redirect remaining output
1399
+ # to devnull to avoid another BrokenPipeError at shutdown
1400
+ devnull = os.open(os.devnull, os.O_WRONLY)
1401
+ os.dup2(devnull, sys.stdout.fileno())
1402
1403
1404
if __name__ == "__main__":
0 commit comments