Skip to content

Commit

Permalink
Add retries to NPS commands
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Nov 28, 2024
1 parent 50b7578 commit 1a392c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [#40](https://github.com/sdss/lvmgort/pull/40) Slight internal restructuring of the core classes `Gort`, `GortClient`, device and remote actor classes. The main goal was to avoid any other part of the library knowing about `GortClient`, which does not include anything not related to its AMQP client function any more.
* Use `Retrier` from `lvmopstools` to handle remote command retries.
* Prevent repeat notifications with the same message.
* Add retries to NPS commands.

### 🔧 Fixed

Expand Down
10 changes: 5 additions & 5 deletions src/gort/devices/nps.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@ async def status(self, outlet: int | str | None = None):
"""Retrieves the status of the power outlet."""

if outlet is None:
reply: ActorReply = await self.actor.commands.status()
reply: ActorReply = await self.actor.commands.status(n_retries=3)
return reply.flatten()["outlets"]
else:
reply: ActorReply = await self.actor.commands.status(outlet)
reply: ActorReply = await self.actor.commands.status(outlet, n_retries=3)
return reply.flatten()["outlet_info"]

async def on(self, outlet: str):
"""Turns an outlet on."""

await self.actor.commands.on(outlet)
await self.actor.commands.on(outlet, n_retries=3)

async def off(self, outlet: str):
"""Turns an outlet on."""

await self.actor.commands.off(outlet)
await self.actor.commands.off(outlet, n_retries=3)

async def all_off(self):
"""Turns off all the outlets."""

self.write_to_log("Turning off all outlets.")
await self.actor.commands.all_off()
await self.actor.commands.all_off(n_retries=3)


class NPSSet(GortDeviceSet[NPS]):
Expand Down

0 comments on commit 1a392c2

Please sign in to comment.