mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
otg msd and big refactoring
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user