From: Ernesto Puerta Date: Fri, 11 Sep 2020 10:10:16 +0000 (+0200) Subject: ceph: ignore BrokenPipeError when printing help X-Git-Tag: v15.2.14~69^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0086e9a954a54fece4d9fd2e5a76feb924afba35;p=ceph.git ceph: ignore BrokenPipeError when printing help ignore BrokenPipeError which is thrown when piping the output of ceph CLI to a tool which might close its stdin before ceph CLI sends the whole help message. Follow approach suggested by Kefu: https://github.com/python/cpython/commit/7b0ed43af55c1e2844aa0ccd5e088b2ddd38dbdb This doesn't manage the clean-up/exit logic, as that's deferred to the last part of the __main__ code. Fixes: https://tracker.ceph.com/issues/47400 Signed-off-by: Ernesto Puerta (cherry picked from commit 39768459f6e542dc4c18407fed4f8412abe759fe) --- diff --git a/src/ceph.in b/src/ceph.in index 25622d4f2e3..3a289092913 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -386,8 +386,11 @@ daemonperf {type.id | path} list|ls [stat-pats] [priority] def do_extended_help(parser, args, target, partial): def help_for_sigs(sigs, partial=None): - sys.stdout.write(format_help(parse_json_funcsigs(sigs, 'cli'), - partial=partial)) + try: + sys.stdout.write(format_help(parse_json_funcsigs(sigs, 'cli'), + partial=partial)) + except BrokenPipeError: + pass def help_for_target(target, partial=None): # wait for osdmap because we know this is sent after the mgrmap