Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGES/2e6eba86.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an issue where ``aiohttp.ClientSession`` would raise an ``Unclosed connector`` warning for externally provided connectors -- by :user:`Ruke3663`.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ Roman Markeloff
Roman Podoliaka
Roman Postnov
Rong Zhang
Ruke 3663
Samir Akarioh
Samuel Colvin
Samuel Gaist
Expand Down
7 changes: 7 additions & 0 deletions aiohttp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM public.ecr.aws/x8v8d7g8/mars-base:latest

WORKDIR /app
COPY . .

RUN pip install -e .[test] pytest aiohttp
CMD ["/bin/bash"]
13 changes: 11 additions & 2 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,15 @@ def __init__(
)

if connector is None:
connector_owner = True
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this is the only line that is potentially related to the title of this PR? Though surely only fixing an issue where someone incorrectly passes connector_owner=False without a connector (in which case we should probably error on the incorrect arguments, rather than just override it).

connector = TCPConnector(ssl_shutdown_timeout=ssl_shutdown_timeout)
elif connector_owner:
warnings.warn(
"connector_owner is deprecated and will be removed in aiohttp 4.0.",
DeprecationWarning,
stacklevel=2,
)

# Initialize these three attrs before raising any exception,
# they are used in __del__
self._connector = connector
Expand All @@ -333,14 +341,15 @@ def __init__(
if connector._loop is not loop:
raise RuntimeError("Session and connector have to use same event loop")

self._connector_owner = connector_owner

if cookie_jar is None:
cookie_jar = CookieJar()
self._cookie_jar = cookie_jar

if cookies:
self._cookie_jar.update_cookies(cookies)

self._connector_owner = connector_owner
self._default_auth = auth
self._version = version
self._json_serialize = json_serialize
Expand Down Expand Up @@ -1282,7 +1291,7 @@ def closed(self) -> bool:

A readonly property.
"""
return self._connector is None or self._connector.closed
return self._connector is None

@property
def connector(self) -> BaseConnector | None:
Expand Down
Loading