From 698430aa669a72196cde6f22aad4e7e83e532bd8 Mon Sep 17 00:00:00 2001 From: Arend-Jan van Hilten Date: Mon, 15 Apr 2024 13:26:34 +0000 Subject: [PATCH] Fix oled slow default --- mirte_telemetrix/scripts/ROS_telemetrix_aio_api.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mirte_telemetrix/scripts/ROS_telemetrix_aio_api.py b/mirte_telemetrix/scripts/ROS_telemetrix_aio_api.py index b830b817..b575b8bd 100755 --- a/mirte_telemetrix/scripts/ROS_telemetrix_aio_api.py +++ b/mirte_telemetrix/scripts/ROS_telemetrix_aio_api.py @@ -751,7 +751,15 @@ async def start(self): def show_default(self, event=None): if not self.default_image: return - asyncio.run(self.show_default_async()) + try: + # the ros service is started on a different thread than the asyncio loop + # When using the normal loop.run_until_complete() function, both threads join in and the oled communication will get broken faster + future = asyncio.run_coroutine_threadsafe( + self.show_default_async(), self.loop + ) + future.result() # wait for it to be done + except Exception as e: + print(e) async def show_default_async(self): text = ""