mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
refactoring
This commit is contained in:
@@ -39,6 +39,8 @@ from typing import TypeVar
|
||||
from typing import Optional
|
||||
from typing import Any
|
||||
|
||||
import aiohttp
|
||||
|
||||
import aiofiles
|
||||
import aiofiles.base
|
||||
|
||||
@@ -93,6 +95,20 @@ async def wait_first(*aws: Awaitable) -> Tuple[Set[asyncio.Future], Set[asyncio.
|
||||
return (await asyncio.wait(list(aws), return_when=asyncio.FIRST_COMPLETED))
|
||||
|
||||
|
||||
# =====
|
||||
def raise_not_200(response: aiohttp.ClientResponse) -> None:
|
||||
if response.status != 200:
|
||||
assert response.reason is not None
|
||||
response.release()
|
||||
raise aiohttp.ClientResponseError(
|
||||
response.request_info,
|
||||
response.history,
|
||||
status=response.status,
|
||||
message=response.reason,
|
||||
headers=response.headers,
|
||||
)
|
||||
|
||||
|
||||
# =====
|
||||
async def afile_write_now(afile: aiofiles.base.AiofilesContextManager, data: bytes) -> None:
|
||||
await afile.write(data)
|
||||
|
||||
Reference in New Issue
Block a user