From a7e785e00c9ce2ad22ea3488a04bc06a83cdf804 Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Sun, 29 Oct 2023 13:45:56 +1100 Subject: [PATCH] Standardize exception variables --- nautilus_trader/backtest/node.py | 4 ++-- nautilus_trader/live/data_engine.py | 16 ++++++++-------- nautilus_trader/live/execution_engine.py | 8 ++++---- nautilus_trader/live/risk_engine.py | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/nautilus_trader/backtest/node.py b/nautilus_trader/backtest/node.py index 2cf35f37fd61..fcfc08f56869 100644 --- a/nautilus_trader/backtest/node.py +++ b/nautilus_trader/backtest/node.py @@ -136,10 +136,10 @@ def run(self) -> list[BacktestResult]: batch_size_bytes=config.batch_size_bytes, ) results.append(result) - except Exception as ex: + except Exception as e: # Broad catch all prevents a single backtest run from halting # the execution of the other backtests (such as a zero balance exception). - print(f"Error running {config}: {ex}") + print(f"Error running {config}: {e}") return results diff --git a/nautilus_trader/live/data_engine.py b/nautilus_trader/live/data_engine.py index f6f008d6eab1..ed594b907427 100644 --- a/nautilus_trader/live/data_engine.py +++ b/nautilus_trader/live/data_engine.py @@ -384,8 +384,8 @@ async def _run_cmd_queue(self) -> None: self._execute_command(command) except asyncio.CancelledError: self._log.warning("DataCommand message queue canceled.") - except RuntimeError as ex: - self._log.error(f"RuntimeError: {ex}.") + except RuntimeError as e: + self._log.error(f"RuntimeError: {e}.") finally: stopped_msg = "DataCommand message queue stopped" if not self._cmd_queue.empty(): @@ -405,8 +405,8 @@ async def _run_req_queue(self) -> None: self._handle_request(request) except asyncio.CancelledError: self._log.warning("DataRequest message queue canceled.") - except RuntimeError as ex: - self._log.error(f"RuntimeError: {ex}.") + except RuntimeError as e: + self._log.error(f"RuntimeError: {e}.") finally: stopped_msg = "DataRequest message queue stopped" if not self._req_queue.empty(): @@ -426,8 +426,8 @@ async def _run_res_queue(self) -> None: self._handle_response(response) except asyncio.CancelledError: self._log.warning("DataResponse message queue canceled.") - except RuntimeError as ex: - self._log.error(f"RuntimeError: {ex}.") + except RuntimeError as e: + self._log.error(f"RuntimeError: {e}.") finally: stopped_msg = "DataResponse message queue stopped" if not self._res_queue.empty(): @@ -445,8 +445,8 @@ async def _run_data_queue(self) -> None: self._handle_data(data) except asyncio.CancelledError: self._log.warning("Data message queue canceled.") - except RuntimeError as ex: - self._log.error(f"RuntimeError: {ex}.") + except RuntimeError as e: + self._log.error(f"RuntimeError: {e}.") finally: stopped_msg = "Data message queue stopped" if not self._data_queue.empty(): diff --git a/nautilus_trader/live/execution_engine.py b/nautilus_trader/live/execution_engine.py index 6b9d7b0c3dec..3fb572950988 100644 --- a/nautilus_trader/live/execution_engine.py +++ b/nautilus_trader/live/execution_engine.py @@ -363,8 +363,8 @@ async def _run_cmd_queue(self) -> None: self._execute_command(command) except asyncio.CancelledError: self._log.warning("Command message queue canceled.") - except RuntimeError as ex: - self._log.error(f"RuntimeError: {ex}.") + except RuntimeError as e: + self._log.error(f"RuntimeError: {e}.") finally: stopped_msg = "Command message queue stopped" if not self._cmd_queue.empty(): @@ -384,8 +384,8 @@ async def _run_evt_queue(self) -> None: self._handle_event(event) except asyncio.CancelledError: self._log.warning("Event message queue canceled.") - except RuntimeError as ex: - self._log.error(f"RuntimeError: {ex}.") + except RuntimeError as e: + self._log.error(f"RuntimeError: {e}.") finally: stopped_msg = "Event message queue stopped" if not self._evt_queue.empty(): diff --git a/nautilus_trader/live/risk_engine.py b/nautilus_trader/live/risk_engine.py index c76ac529a41c..1f3840390e8c 100644 --- a/nautilus_trader/live/risk_engine.py +++ b/nautilus_trader/live/risk_engine.py @@ -249,8 +249,8 @@ async def _run_cmd_queue(self) -> None: self._execute_command(command) except asyncio.CancelledError: self._log.warning("Command message queue canceled.") - except RuntimeError as ex: - self._log.error(f"RuntimeError: {ex}.") + except RuntimeError as e: + self._log.error(f"RuntimeError: {e}.") finally: stopped_msg = "Command message queue stopped" if not self._cmd_queue.empty(): @@ -270,8 +270,8 @@ async def _run_evt_queue(self) -> None: self._handle_event(event) except asyncio.CancelledError: self._log.warning("Event message queue canceled.") - except RuntimeError as ex: - self._log.error(f"RuntimeError: {ex}.") + except RuntimeError as e: + self._log.error(f"RuntimeError: {e}.") finally: stopped_msg = "Event message queue stopped" if not self._evt_queue.empty():