diff options
author | Maxim Devaev <[email protected]> | 2024-10-26 15:51:33 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2024-10-26 15:51:33 +0300 |
commit | a84242c9bc5215c7230dd9552cbbeec786060ec3 (patch) | |
tree | 7918ea96b79a3e20f2142d5fac2cdf242c5ece80 /kvmd | |
parent | 399712c6849b52efcb1b1ee9f4abdafa84c5812f (diff) |
AioExclusiveRegion API is sync now
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/aiotools.py | 14 | ||||
-rw-r--r-- | kvmd/apps/kvmd/ugpio.py | 2 | ||||
-rw-r--r-- | kvmd/plugins/atx/gpio.py | 2 | ||||
-rw-r--r-- | kvmd/plugins/msd/otg/__init__.py | 6 |
4 files changed, 12 insertions, 12 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py index b1747f16..a47c94c6 100644 --- a/kvmd/aiotools.py +++ b/kvmd/aiotools.py @@ -297,7 +297,7 @@ class AioExclusiveRegion: def is_busy(self) -> bool: return self.__busy - async def enter(self) -> None: + def enter(self) -> None: if not self.__busy: self.__busy = True try: @@ -309,22 +309,22 @@ class AioExclusiveRegion: return raise self.__exc_type() - async def exit(self) -> None: + def exit(self) -> None: self.__busy = False if self.__notifier: self.__notifier.notify() - async def __aenter__(self) -> None: - await self.enter() + def __enter__(self) -> None: + self.enter() - async def __aexit__( + def __exit__( self, _exc_type: type[BaseException], _exc: BaseException, _tb: types.TracebackType, ) -> None: - await self.exit() + self.exit() async def run_region_task( @@ -339,7 +339,7 @@ async def run_region_task( async def wrapper() -> None: try: - async with region: + with region: entered.set_result(None) await func(*args, **kwargs) except region.get_exc_type(): diff --git a/kvmd/apps/kvmd/ugpio.py b/kvmd/apps/kvmd/ugpio.py index 11c60777..b5b4a621 100644 --- a/kvmd/apps/kvmd/ugpio.py +++ b/kvmd/apps/kvmd/ugpio.py @@ -185,7 +185,7 @@ class _GpioOutput: # pylint: disable=too-many-instance-attributes @aiotools.atomic_fg async def __run_action(self, wait: bool, name: str, func: Callable, *args: Any) -> None: if wait: - async with self.__region: + with self.__region: await func(*args) else: await aiotools.run_region_task( diff --git a/kvmd/plugins/atx/gpio.py b/kvmd/plugins/atx/gpio.py index e42b3959..578d2717 100644 --- a/kvmd/plugins/atx/gpio.py +++ b/kvmd/plugins/atx/gpio.py @@ -191,7 +191,7 @@ class Plugin(BaseAtx): # pylint: disable=too-many-instance-attributes @aiotools.atomic_fg async def __click(self, name: str, pin: int, delay: float, wait: bool) -> None: if wait: - async with self.__region: + with self.__region: await self.__inner_click(name, pin, delay) else: await aiotools.run_region_task( diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py index 7c2c7a9e..203e0b95 100644 --- a/kvmd/plugins/msd/otg/__init__.py +++ b/kvmd/plugins/msd/otg/__init__.py @@ -96,7 +96,7 @@ class _State: @contextlib.asynccontextmanager async def busy(self, check_online: bool=True) -> AsyncGenerator[None, None]: - async with self._region: + with self._region: async with self._lock: self.__notifier.notify() if check_online: @@ -292,7 +292,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes @contextlib.asynccontextmanager async def read_image(self, name: str) -> AsyncGenerator[MsdFileReader, None]: try: - async with self.__state._region: # pylint: disable=protected-access + with self.__state._region: # pylint: disable=protected-access try: async with self.__state._lock: # pylint: disable=protected-access self.__notifier.notify() @@ -313,7 +313,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes @contextlib.asynccontextmanager async def write_image(self, name: str, size: int, remove_incomplete: (bool | None)) -> AsyncGenerator[MsdFileWriter, None]: try: - async with self.__state._region: # pylint: disable=protected-access + with self.__state._region: # pylint: disable=protected-access image: (Image | None) = None try: async with self.__state._lock: # pylint: disable=protected-access |