From 75d9b858d73bf3ed31597e554b27520e3e31f72e Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Sat, 29 Feb 2020 17:23:57 +0300 Subject: moved AioExclusiveRegion to aiotools --- kvmd/plugins/atx/gpio.py | 5 ++--- kvmd/plugins/msd/otg/__init__.py | 3 +-- kvmd/plugins/msd/relay.py | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'kvmd/plugins') diff --git a/kvmd/plugins/atx/gpio.py b/kvmd/plugins/atx/gpio.py index c657a7f3..cca58a18 100644 --- a/kvmd/plugins/atx/gpio.py +++ b/kvmd/plugins/atx/gpio.py @@ -29,7 +29,6 @@ from typing import AsyncGenerator from ...logging import get_logger from ... import aiotools -from ... import aioregion from ... import gpio from ...yamlconf import Option @@ -75,7 +74,7 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes self.__state_poll = state_poll - self.__region = aioregion.AioExclusiveRegion(AtxIsBusyError) + self.__region = aiotools.AioExclusiveRegion(AtxIsBusyError) @classmethod def get_plugin_options(cls) -> Dict: @@ -163,7 +162,7 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes @aiotools.atomic async def __click(self, name: str, pin: int, delay: float) -> None: - with aiotools.unregion_only_on_exception(self.__region): + with self.__region.exit_only_on_exception(): await self.__inner_click(name, pin, delay) @aiotools.tasked diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py index 41e1653f..f3695530 100644 --- a/kvmd/plugins/msd/otg/__init__.py +++ b/kvmd/plugins/msd/otg/__init__.py @@ -45,7 +45,6 @@ from ....validators.os import valid_abs_dir from ....validators.os import valid_command from .... import aiotools -from .... import aioregion from .. import MsdError from .. import MsdIsBusyError @@ -111,7 +110,7 @@ class _State: self.vd: Optional[_VirtualDriveState] = None self._lock = asyncio.Lock() - self._region = aioregion.AioExclusiveRegion(MsdIsBusyError) + self._region = aiotools.AioExclusiveRegion(MsdIsBusyError) @contextlib.asynccontextmanager async def busy(self, check_online: bool=True) -> AsyncGenerator[None, None]: diff --git a/kvmd/plugins/msd/relay.py b/kvmd/plugins/msd/relay.py index 4e621cc2..81456efa 100644 --- a/kvmd/plugins/msd/relay.py +++ b/kvmd/plugins/msd/relay.py @@ -40,7 +40,6 @@ import aiofiles.base from ...logging import get_logger from ... import aiotools -from ... import aioregion from ... import gpio from ...yamlconf import Option @@ -174,7 +173,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes self.__init_retries = init_retries self.__reset_delay = reset_delay - self.__region = aioregion.AioExclusiveRegion(MsdIsBusyError) + self.__region = aiotools.AioExclusiveRegion(MsdIsBusyError) self.__device_info: Optional[_DeviceInfo] = None self.__connected = False @@ -235,7 +234,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes @aiotools.atomic async def reset(self) -> None: - with aiotools.unregion_only_on_exception(self.__region): + with self.__region.exit_only_on_exception(): await self.__inner_reset() @aiotools.tasked -- cgit v1.2.3