summaryrefslogtreecommitdiff
path: root/kvmd/aiotools.py
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/aiotools.py')
-rw-r--r--kvmd/aiotools.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/kvmd/aiotools.py b/kvmd/aiotools.py
index a2bed6bf..bd4bd37e 100644
--- a/kvmd/aiotools.py
+++ b/kvmd/aiotools.py
@@ -39,6 +39,8 @@ from typing import TypeVar
from typing import Optional
from typing import Any
+import aiohttp
+
import aiofiles
import aiofiles.base
@@ -94,6 +96,20 @@ async def wait_first(*aws: Awaitable) -> Tuple[Set[asyncio.Future], Set[asyncio.
# =====
+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)
await afile.flush()