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

Update aiohttp to 3.9.0b0 #101627

Merged
merged 2 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions homeassistant/components/hassio/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,8 @@ async def _handle(self, request: web.Request, path: str) -> web.StreamResponse:
# _stored_content_type is only computed once `content_type` is accessed
if path == "backups/new/upload":
# We need to reuse the full content type that includes the boundary
headers[
CONTENT_TYPE
] = request._stored_content_type # pylint: disable=protected-access
# pylint: disable-next=protected-access
headers[CONTENT_TYPE] = request._stored_content_type # type: ignore[assignment]

try:
client = await self._websession.request(
Expand Down
14 changes: 12 additions & 2 deletions homeassistant/helpers/aiohttp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import asyncio
from collections.abc import Awaitable, Callable
from contextlib import suppress
from ssl import SSLContext
import sys
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, cast
Expand Down Expand Up @@ -59,6 +58,17 @@
MAXIMUM_CONNECTIONS_PER_HOST = 100


# Overwrite base aiohttp _wait implementation
# Homeassistant has a custom shutdown wait logic.
Comment on lines +61 to +62

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdce8p Would a cleaner approach work by just setting shutdown_timeout to 0?

If not, then maybe there are some improvements to be made in aiohttp...

I'd also be curious how homeassistant's shutdown logic works.

async def _noop_wait(*args: Any, **kwargs: Any) -> None:
"""Do nothing."""
return


# pylint: disable-next=protected-access
web.BaseSite._wait = _noop_wait # type: ignore[method-assign]


class HassClientResponse(aiohttp.ClientResponse):
"""aiohttp.ClientResponse with a json method that uses json_loads by default."""

Expand Down Expand Up @@ -276,7 +286,7 @@ def _async_get_connector(
return cast(aiohttp.BaseConnector, hass.data[key])

if verify_ssl:
ssl_context: bool | SSLContext = ssl_util.get_default_context()
ssl_context = ssl_util.get_default_context()
else:
ssl_context = ssl_util.get_default_no_verify_context()

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
aiodiscover==1.5.1
aiohttp==3.8.6
aiohttp==3.9.0b0
aiohttp_cors==0.7.0
astral==2.2
async-upnp-client==0.36.1
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
]
requires-python = ">=3.11.0"
dependencies = [
"aiohttp==3.8.6",
"aiohttp==3.9.0b0",
"astral==2.2",
"attrs==23.1.0",
"atomicwrites-homeassistant==1.4.1",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-c homeassistant/package_constraints.txt

# Home Assistant Core
aiohttp==3.8.6
aiohttp==3.9.0b0
astral==2.2
attrs==23.1.0
atomicwrites-homeassistant==1.4.1
Expand Down
2 changes: 1 addition & 1 deletion tests/components/generic/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async def test_limit_refetch(
hass.states.async_set("sensor.temp", "5")

with pytest.raises(aiohttp.ServerTimeoutError), patch(
"async_timeout.timeout", side_effect=asyncio.TimeoutError()
"asyncio.timeout", side_effect=asyncio.TimeoutError()
):
resp = await client.get("/api/camera_proxy/camera.config_test")

Expand Down
2 changes: 1 addition & 1 deletion tests/util/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_serialize_body_str() -> None:
assert aiohttp.serialize_response(response) == {
"status": 201,
"body": "Hello",
"headers": {"Content-Length": "5", "Content-Type": "text/plain; charset=utf-8"},
"headers": {"Content-Type": "text/plain; charset=utf-8"},
}


Expand Down