From 2e707113bbeb189b5bd607abaa70f65bb26a25a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20S=C3=A1nchez-Gallego?= Date: Tue, 30 Jan 2024 19:14:38 -0800 Subject: [PATCH] Fix bug in LCO lamps --- src/hal/helpers/lamps.py | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/hal/helpers/lamps.py b/src/hal/helpers/lamps.py index a6c641b..dcfd3b8 100644 --- a/src/hal/helpers/lamps.py +++ b/src/hal/helpers/lamps.py @@ -301,23 +301,22 @@ async def turn_lamp( if status[ll][0] is not False: turn_off_tasks.append(self._command_one(command, ll, False)) - if len(turn_off_tasks) > 0: - try: - if len(turn_off_tasks) > 0: - await asyncio.gather(*turn_off_tasks) - - await asyncio.gather(*tasks) - except Exception as err: - if is_retry: - raise - else: - command.warning(f"Failed commanding lamps: {err}") - command.warning("Retrying lamps.") - return await self.turn_lamp( - command, - lamps, - state, - turn_off_others=turn_off_others, - delay=delay, - is_retry=True, - ) + try: + if len(turn_off_tasks) > 0: + await asyncio.gather(*turn_off_tasks) + + await asyncio.gather(*tasks) + except Exception as err: + if is_retry: + raise + else: + command.warning(f"Failed commanding lamps: {err}") + command.warning("Retrying lamps.") + return await self.turn_lamp( + command, + lamps, + state, + turn_off_others=turn_off_others, + delay=delay, + is_retry=True, + )