mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 09:01:54 +08:00
Simplified inotify API
This commit is contained in:
@@ -28,7 +28,6 @@ from typing import Any
|
||||
|
||||
from ...logging import get_logger
|
||||
|
||||
from ...inotify import InotifyMask
|
||||
from ...inotify import Inotify
|
||||
|
||||
from ... import aiotools
|
||||
@@ -82,15 +81,15 @@ class Plugin(BaseUserGpioDriver):
|
||||
await asyncio.sleep(5)
|
||||
|
||||
with Inotify() as inotify:
|
||||
await inotify.watch(InotifyMask.ALL_MODIFY_EVENTS, os.path.dirname(self.__udc_path))
|
||||
await inotify.watch(InotifyMask.ALL_MODIFY_EVENTS, self.__profile_path)
|
||||
await inotify.watch_all_modify(os.path.dirname(self.__udc_path))
|
||||
await inotify.watch_all_modify(self.__profile_path)
|
||||
self._notifier.notify()
|
||||
while True:
|
||||
need_restart = False
|
||||
need_notify = False
|
||||
for event in (await inotify.get_series(timeout=1)):
|
||||
need_notify = True
|
||||
if event.mask & (InotifyMask.DELETE_SELF | InotifyMask.MOVE_SELF | InotifyMask.UNMOUNT):
|
||||
if event.restart:
|
||||
logger.warning("Got fatal inotify event: %s; reinitializing OTG-bind ...", event)
|
||||
need_restart = True
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user