diff options
author | Maxim Devaev <[email protected]> | 2023-03-16 20:35:04 +0200 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2023-03-16 20:35:04 +0200 |
commit | 27f38ef086842a871ff4768ebda46e1348fee2e0 (patch) | |
tree | a1f160421539dab8682b4546bef8e3627279e199 /kvmd/inotify.py | |
parent | 59b1d8abbbb9225ec3164069acc74ec590b93f7b (diff) |
more msd async
Diffstat (limited to 'kvmd/inotify.py')
-rw-r--r-- | kvmd/inotify.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kvmd/inotify.py b/kvmd/inotify.py index d76e73e3..fe9b6391 100644 --- a/kvmd/inotify.py +++ b/kvmd/inotify.py @@ -34,6 +34,7 @@ from typing import Generator from .logging import get_logger +from . import aiotools from . import libc @@ -189,11 +190,12 @@ class Inotify: self.__events_queue: "asyncio.Queue[InotifyEvent]" = asyncio.Queue() - def watch(self, path: str, mask: int) -> None: + async def watch(self, path: str, mask: int) -> None: path = os.path.normpath(path) assert path not in self.__wd_by_path, path get_logger().info("Watching for %s", path) - wd = _inotify_check(libc.inotify_add_watch(self.__fd, _fs_encode(path), mask)) + # Асинхронно, чтобы не висло на NFS + wd = _inotify_check(await aiotools.run_async(libc.inotify_add_watch, self.__fd, _fs_encode(path), mask)) self.__wd_by_path[path] = wd self.__path_by_wd[wd] = path |