From 35773228e0be37bf6801f275bf9181e6636d903d Mon Sep 17 00:00:00 2001 From: Austin Raney Date: Wed, 24 Jan 2024 14:28:14 -0500 Subject: [PATCH] bug: only call shutdown finalizer if loop is running --- .../communication/dmod/communication/websocket_interface.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/lib/communication/dmod/communication/websocket_interface.py b/python/lib/communication/dmod/communication/websocket_interface.py index 0de4f9893..9cbf45e59 100644 --- a/python/lib/communication/dmod/communication/websocket_interface.py +++ b/python/lib/communication/dmod/communication/websocket_interface.py @@ -87,7 +87,8 @@ def _get_async_loop(cls): def __del__(self): try: - asyncio.run(self.shutdown()) + if self._loop.is_running(): + self._loop.run_until_complete(self.shutdown()) except Exception as e: pass