otg msd and big refactoring

This commit is contained in:
Devaev Maxim
2019-10-29 02:16:12 +03:00
parent f6214191af
commit 10f8c2b335
15 changed files with 1300 additions and 356 deletions

View File

@@ -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())