summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-03-01 04:30:32 +0300
committerDevaev Maxim <[email protected]>2020-03-01 04:30:32 +0300
commit44b0ab19bf33a2bdd0d9637f14128f968cf1764e (patch)
tree268d522f27e223ee96f7cfbac12a40c9e0ff5435
parentff6e284e64c0e0a9e496fc047786a7d9c3aa907b (diff)
no more busyloops in stub plugins
-rw-r--r--kvmd/aiotools.py5
-rw-r--r--kvmd/plugins/atx/disabled.py6
-rw-r--r--kvmd/plugins/msd/disabled.py5
3 files changed, 11 insertions, 5 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py
index 993209d1..9f854489 100644
--- a/kvmd/aiotools.py
+++ b/kvmd/aiotools.py
@@ -105,6 +105,11 @@ def run_sync(coro: Coroutine[Any, Any, _RetvalT]) -> _RetvalT:
# =====
+async def wait_infinite() -> None:
+ await asyncio.get_event_loop().create_future()
+
+
+# =====
@contextlib.asynccontextmanager
async def unlock_only_on_exception(lock: asyncio.Lock) -> AsyncGenerator[None, None]:
await lock.acquire()
diff --git a/kvmd/plugins/atx/disabled.py b/kvmd/plugins/atx/disabled.py
index 09fad2f8..d480a337 100644
--- a/kvmd/plugins/atx/disabled.py
+++ b/kvmd/plugins/atx/disabled.py
@@ -20,11 +20,11 @@
# ========================================================================== #
-import asyncio
-
from typing import Dict
from typing import AsyncGenerator
+from ... import aiotools
+
from . import AtxOperationError
from . import BaseAtx
@@ -50,7 +50,7 @@ class Plugin(BaseAtx):
async def poll_state(self) -> AsyncGenerator[Dict, None]:
while True:
yield self.get_state()
- await asyncio.sleep(60)
+ await aiotools.wait_infinite()
# =====
diff --git a/kvmd/plugins/msd/disabled.py b/kvmd/plugins/msd/disabled.py
index 97835513..4dacf1e4 100644
--- a/kvmd/plugins/msd/disabled.py
+++ b/kvmd/plugins/msd/disabled.py
@@ -20,13 +20,14 @@
# ========================================================================== #
-import asyncio
import contextlib
from typing import Dict
from typing import AsyncGenerator
from typing import Optional
+from ... import aiotools
+
from . import MsdOperationError
from . import BaseMsd
@@ -55,7 +56,7 @@ class Plugin(BaseMsd):
async def poll_state(self) -> AsyncGenerator[Dict, None]:
while True:
yield (await self.get_state())
- await asyncio.sleep(60)
+ await aiotools.wait_infinite()
async def reset(self) -> None:
raise MsdDisabledError()