From df492245a3438ca8d1f85d550fec76fb56c82390 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Wed, 9 Aug 2023 11:36:37 +0200 Subject: [PATCH] [utilities] catch SoSTimeoutError in sos_get_command_output When calling collect_cmd_output and timeout is hit, SoSTimeoutError is raised and never caught (until in plugin wrapper). Resolves: #3331 Signed-off-by: Pavel Moravec --- sos/utilities.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sos/utilities.py b/sos/utilities.py index 5e7b2315f5..c1d3e7476c 100644 --- a/sos/utilities.py +++ b/sos/utilities.py @@ -233,7 +233,15 @@ def _check_poller(proc): if poller: while reader.running: - _check_poller(p) + try: + _check_poller(p) + except SoSTimeoutError: + p.terminate() + if to_file: + _output.close() + reader.running = False + return {'status': 124, 'output': reader.get_contents(), + 'truncated': reader.is_full} else: try: # override timeout=0 to timeout=None, as Popen will treat the