summaryrefslogtreecommitdiff
path: root/kvmd/aiotools.py
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-06-18 13:10:00 +0300
committerMaxim Devaev <[email protected]>2022-06-18 13:10:00 +0300
commitb5344a5f3a17a5d3a354ee4d4c9894e068da6985 (patch)
tree9f9a877a3923174fee1932a528372cb9776605ff /kvmd/aiotools.py
parent53e64fe1518d7dd8d53c6e04846cee1601c2c754 (diff)
refactoring
Diffstat (limited to 'kvmd/aiotools.py')
-rw-r--r--kvmd/aiotools.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py
index 125e2779..ee5e86d7 100644
--- a/kvmd/aiotools.py
+++ b/kvmd/aiotools.py
@@ -43,16 +43,16 @@ from .logging import get_logger
# =====
-_MethodT = TypeVar("_MethodT", bound=Callable[..., Any])
+_FunctionT = TypeVar("_FunctionT", bound=Callable[..., Any])
_RetvalT = TypeVar("_RetvalT")
# =====
-def atomic(method: _MethodT) -> _MethodT:
- @functools.wraps(method)
+def atomic(func: _FunctionT) -> _FunctionT:
+ @functools.wraps(func)
async def wrapper(*args: Any, **kwargs: Any) -> Any:
- return (await asyncio.shield(method(*args, **kwargs)))
- return typing.cast(_MethodT, wrapper)
+ return (await asyncio.shield(func(*args, **kwargs)))
+ return typing.cast(_FunctionT, wrapper)
# =====
@@ -109,8 +109,8 @@ async def stop_all_deadly_tasks() -> None:
# =====
-async def run_async(method: Callable[..., _RetvalT], *args: Any) -> _RetvalT:
- return (await asyncio.get_running_loop().run_in_executor(None, method, *args))
+async def run_async(func: Callable[..., _RetvalT], *args: Any) -> _RetvalT:
+ return (await asyncio.get_running_loop().run_in_executor(None, func, *args))
def run_sync(coro: Coroutine[Any, Any, _RetvalT]) -> _RetvalT:
@@ -254,7 +254,7 @@ class AioExclusiveRegion:
async def run_region_task(
msg: str,
region: AioExclusiveRegion,
- method: Callable[..., Coroutine[Any, Any, None]],
+ func: Callable[..., Coroutine[Any, Any, None]],
*args: Any,
**kwargs: Any,
) -> None:
@@ -265,7 +265,7 @@ async def run_region_task(
try:
async with region:
entered.set_result(None)
- await method(*args, **kwargs)
+ await func(*args, **kwargs)
except region.get_exc_type():
raise
except Exception: