From 44b16f9d73d8d096103840a15f77334252ea9090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20S=C3=A1nchez-Gallego?= Date: Sat, 11 Jan 2025 14:15:47 +0000 Subject: [PATCH] Use asyncio.wait_for instead of with_timeout and increase timeout to 10 seconds --- src/lvmcryo/handlers/valve.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lvmcryo/handlers/valve.py b/src/lvmcryo/handlers/valve.py index c3cc528..829f09f 100644 --- a/src/lvmcryo/handlers/valve.py +++ b/src/lvmcryo/handlers/valve.py @@ -19,7 +19,6 @@ from lvmopstools.clu import CluClient from lvmopstools.retrier import Retrier -from lvmopstools.utils import with_timeout from lvmcryo.config import get_internal_config from lvmcryo.handlers.thermistor import ThermistorHandler @@ -94,7 +93,7 @@ async def valve_on_off( if on is True and isinstance(timeout, (int, float)) and use_script is True: # First we need to get the outlet number. - info = await with_timeout(outlet_info(actor, outlet_name), timeout=5) + info = await asyncio.wait_for(outlet_info(actor, outlet_name), timeout=10) id_ = info["id"] command_string = f"scripts run cycle_with_timeout {id_} {timeout}" @@ -149,7 +148,7 @@ async def close_all_valves(config: Configuration | None = None, dry_run: bool = await asyncio.gather( *[ - with_timeout( + asyncio.wait_for( valve_on_off( valve_info[valve]["actor"], valve_info[valve]["outlet"], @@ -214,7 +213,10 @@ async def check(self): """Check the connection to the NPS.""" try: - info = await with_timeout(outlet_info(self.actor, self.outlet), timeout=5) + info = await asyncio.wait_for( + outlet_info(self.actor, self.outlet), + timeout=10, + ) assert isinstance(info, dict), "Invalid outlet info." assert not info["state"], "Valve is already open." except Exception as err: