Skip to content

Commit

Permalink
Use asyncio.wait_for instead of with_timeout and increase timeout to …
Browse files Browse the repository at this point in the history
…10 seconds
  • Loading branch information
albireox committed Jan 11, 2025
1 parent 2d0684a commit 44b16f9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lvmcryo/handlers/valve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 44b16f9

Please sign in to comment.