mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
no more busyloops in stub plugins
This commit is contained in:
parent
ff6e284e64
commit
44b0ab19bf
@ -104,6 +104,11 @@ def run_sync(coro: Coroutine[Any, Any, _RetvalT]) -> _RetvalT:
|
||||
return asyncio.get_event_loop().run_until_complete(coro)
|
||||
|
||||
|
||||
# =====
|
||||
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]:
|
||||
|
||||
@ -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()
|
||||
|
||||
# =====
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user