new events model

This commit is contained in:
Maxim Devaev
2024-10-21 17:46:59 +03:00
parent b67a232584
commit cda32a083f
30 changed files with 335 additions and 165 deletions

View File

@@ -40,6 +40,9 @@ class MsdDisabledError(MsdOperationError):
# =====
class Plugin(BaseMsd):
def __init__(self) -> None:
self.__notifier = aiotools.AioNotifier()
async def get_state(self) -> dict:
return {
"enabled": False,
@@ -49,10 +52,13 @@ class Plugin(BaseMsd):
"drive": None,
}
async def trigger_state(self) -> None:
self.__notifier.notify()
async def poll_state(self) -> AsyncGenerator[dict, None]:
while True:
await self.__notifier.wait()
yield (await self.get_state())
await aiotools.wait_infinite()
async def reset(self) -> None:
raise MsdDisabledError()