From 641e46e190693a30ef26d1d5a287d043d284490c Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 6 Feb 2025 09:57:31 -0800 Subject: [PATCH] Remove some noise in pause and abort handling --- src/prefect/engine.py | 13 ++++--------- src/prefect/flow_engine.py | 16 ++++++++-------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/prefect/engine.py b/src/prefect/engine.py index a2829a7a2001..4c4dedb6a7b5 100644 --- a/src/prefect/engine.py +++ b/src/prefect/engine.py @@ -62,18 +62,13 @@ else: run_flow(flow, flow_run=flow_run, error_logger=run_logger) - except Abort as abort_signal: - abort_signal: Abort + except Abort: engine_logger.info( - f"Engine execution of flow run '{flow_run_id}' aborted by orchestrator:" - f" {abort_signal}" + "Engine execution of flow run '{flow_run_id}' aborted by orchestrator." ) exit(0) - except Pause as pause_signal: - pause_signal: Pause - engine_logger.info( - f"Engine execution of flow run '{flow_run_id}' is paused: {pause_signal}" - ) + except Pause: + engine_logger.info(f"Engine execution of flow run '{flow_run_id}' is paused.") exit(0) except Exception: engine_logger.error( diff --git a/src/prefect/flow_engine.py b/src/prefect/flow_engine.py index 92e370aff336..6900de662a0b 100644 --- a/src/prefect/flow_engine.py +++ b/src/prefect/flow_engine.py @@ -1518,6 +1518,8 @@ def run_flow( ret_val = run_flow_async(**kwargs) else: ret_val = run_flow_sync(**kwargs) + except (Abort, Pause): + raise except: if error_logger: error_logger.error( @@ -1597,20 +1599,18 @@ def run_flow_with_env( # This is running in a brand new process, so there won't be an existing # event loop. asyncio.run(maybe_coro) - except Abort as abort_signal: - abort_signal: Abort + except Abort: if flow_run: - msg = f"Execution of flow run '{flow_run.id}' aborted by orchestrator: {abort_signal}" + msg = f"Execution of flow run '{flow_run.id}' aborted by orchestrator." else: - msg = f"Execution aborted by orchestrator: {abort_signal}" + msg = "Execution aborted by orchestrator." engine_logger.info(msg) exit(0) - except Pause as pause_signal: - pause_signal: Pause + except Pause: if flow_run: - msg = f"Execution of flow run '{flow_run.id}' is paused: {pause_signal}" + msg = f"Execution of flow run '{flow_run.id}' is paused." else: - msg = f"Execution is paused: {pause_signal}" + msg = "Execution is paused." engine_logger.info(msg) exit(0) except Exception: