AioExclusiveRegion API is sync now

This commit is contained in:
Maxim Devaev
2024-10-26 15:51:33 +03:00
parent 399712c684
commit a84242c9bc
5 changed files with 23 additions and 23 deletions

View File

@@ -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(

View File

@@ -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