Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove outdated codes that use 'AsyncCM' interface #874

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions aiodocker/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import shlex
import tarfile
from contextlib import AbstractAsyncContextManager
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -18,7 +19,7 @@
overload,
)

from aiohttp import ClientWebSocketResponse
from aiohttp import ClientResponse, ClientWebSocketResponse
from multidict import MultiDict
from yarl import URL

Expand Down Expand Up @@ -196,19 +197,22 @@ def log(
else:
return self._logs_list(cm)

async def _logs_stream(self, cm):
async def _logs_stream(
self, cm: AbstractAsyncContextManager[ClientResponse]
) -> AsyncIterator[str]:
try:
inspect_info = await self.show()
except DockerError:
cm.cancel()
raise
is_tty = inspect_info["Config"]["Tty"]

async with cm as response:
async for item in multiplexed_result_stream(response, is_tty=is_tty):
yield item

async def _logs_list(self, cm):
async def _logs_list(
self, cm: AbstractAsyncContextManager[ClientResponse]
) -> Sequence[str]:
try:
inspect_info = await self.show()
except DockerError:
Expand All @@ -225,6 +229,7 @@ async def get_archive(self, path: str) -> tarfile.TarFile:
params={"path": path},
) as response:
data = await parse_result(response)
assert isinstance(data, tarfile.TarFile)
return data

async def put_archive(self, path, data):
Expand Down