From ae07595ca50593c7844f2f2281381827da13fce6 Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Mon, 18 Nov 2024 11:50:53 +1100 Subject: [PATCH] Improve live engines error logging --- RELEASES.md | 1 + nautilus_trader/live/data_engine.py | 16 ++++++++-------- nautilus_trader/live/execution_engine.py | 8 ++++---- nautilus_trader/live/risk_engine.py | 8 ++++---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 87748c2ad41..378c113a649 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -6,6 +6,7 @@ Released on TBD (UTC). None ### Internal Improvements +- Improve live engines error logging (will now log all exceptions rather than just `RuntimeError`) - Upgraded `datafusion` crate to v43.0.0 (#2056), thanks @twitu ### Breaking Changes diff --git a/nautilus_trader/live/data_engine.py b/nautilus_trader/live/data_engine.py index 8d05a5c04a6..b013c3d99ec 100644 --- a/nautilus_trader/live/data_engine.py +++ b/nautilus_trader/live/data_engine.py @@ -390,8 +390,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 e: - self._log.error(f"RuntimeError: {e}") + except Exception as e: + self._log.error(repr(e)) finally: stopped_msg = "DataCommand message queue stopped" if not self._cmd_queue.empty(): @@ -411,8 +411,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 e: - self._log.error(f"RuntimeError: {e}") + except Exception as e: + self._log.error(repr(e)) finally: stopped_msg = "DataRequest message queue stopped" if not self._req_queue.empty(): @@ -432,8 +432,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 e: - self._log.error(f"RuntimeError: {e}") + except Exception as e: + self._log.error(repr(e)) finally: stopped_msg = "DataResponse message queue stopped" if not self._res_queue.empty(): @@ -451,8 +451,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 e: - self._log.error(f"RuntimeError: {e}") + except Exception as e: + self._log.error(repr(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 e256dfc82cc..8c87ac331ec 100644 --- a/nautilus_trader/live/execution_engine.py +++ b/nautilus_trader/live/execution_engine.py @@ -398,8 +398,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 e: - self._log.error(f"RuntimeError: {e}") + except Exception as e: + self._log.error(repr(e)) finally: stopped_msg = "Command message queue stopped" if not self._cmd_queue.empty(): @@ -419,8 +419,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 e: - self._log.error(f"RuntimeError: {e}") + except Exception as e: + self._log.error(repr(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 6a14dfbfbc0..61581828ee4 100644 --- a/nautilus_trader/live/risk_engine.py +++ b/nautilus_trader/live/risk_engine.py @@ -244,8 +244,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 e: - self._log.error(f"RuntimeError: {e}") + except Exception as e: + self._log.error(repr(e)) finally: stopped_msg = "Command message queue stopped" if not self._cmd_queue.empty(): @@ -265,8 +265,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 e: - self._log.error(f"RuntimeError: {e}") + except Exception as e: + self._log.error(repr(e)) finally: stopped_msg = "Event message queue stopped" if not self._evt_queue.empty():