diff options
author | Devaev Maxim <[email protected]> | 2019-10-29 02:16:12 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-11-07 01:27:07 +0300 |
commit | 10f8c2b3352c951549cc1249d6b24789fb94d688 (patch) | |
tree | cbf38bcf2716896db748f64bcae66375b7135287 /kvmd/aiotools.py | |
parent | f6214191af093560d5697cd7b1ea6f245ee95b98 (diff) |
otg msd and big refactoring
Diffstat (limited to 'kvmd/aiotools.py')
-rw-r--r-- | kvmd/aiotools.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py index 574c8bc7..98a2a524 100644 --- a/kvmd/aiotools.py +++ b/kvmd/aiotools.py @@ -20,6 +20,7 @@ # ========================================================================== # +import os import asyncio import functools import contextlib @@ -34,6 +35,9 @@ from typing import AsyncGenerator from typing import TypeVar from typing import Any +import aiofiles +import aiofiles.base + from . import aioregion from .logging import get_logger @@ -118,3 +122,10 @@ async def unlock_only_on_exception(lock: asyncio.Lock) -> AsyncGenerator[None, N except: # noqa: E722 lock.release() raise + + +# ===== +async def afile_write_now(afile: aiofiles.base.AiofilesContextManager, data: bytes) -> None: + await afile.write(data) + await afile.flush() + await run_async(os.fsync, afile.fileno()) |