diff options
author | Devaev Maxim <[email protected]> | 2020-03-03 23:48:53 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-03-03 23:48:53 +0300 |
commit | 552bb93212ef2a890b1493b2d9be022d3ece802b (patch) | |
tree | 7ce3dd397b5fa6a78fac54f5d4c9d3bf71366008 /kvmd/plugins/atx | |
parent | 3b16242cfa4b656ba7d396a600b452184aac6c76 (diff) |
atomic fixes, removed tasked and muted
Diffstat (limited to 'kvmd/plugins/atx')
-rw-r--r-- | kvmd/plugins/atx/gpio.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/kvmd/plugins/atx/gpio.py b/kvmd/plugins/atx/gpio.py index 51b063bc..0ed29b49 100644 --- a/kvmd/plugins/atx/gpio.py +++ b/kvmd/plugins/atx/gpio.py @@ -162,19 +162,17 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes @aiotools.atomic async def __click(self, name: str, pin: int, delay: float) -> None: - async with self.__region.exit_only_on_exception(): - await self.__inner_click(name, pin, delay) + await aiotools.run_region_task( + "Can't perform ATX click or operation was not completed", + self.__region, self.__inner_click, name, pin, delay, + ) - @aiotools.tasked - @aiotools.muted("Can't perform ATX click or operation was not completed") + @aiotools.atomic async def __inner_click(self, name: str, pin: int, delay: float) -> None: try: gpio.write(pin, True) await asyncio.sleep(delay) finally: - try: - gpio.write(pin, False) - await asyncio.sleep(1) - finally: - await self.__region.exit() + gpio.write(pin, False) + await asyncio.sleep(1) get_logger(0).info("Clicked ATX button %r", name) |