Skip to content

Commit

Permalink
Fix ChainProxyConnector
Browse files Browse the repository at this point in the history
  • Loading branch information
romis2012 committed Sep 4, 2023
1 parent 05f5228 commit 7ad35e5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions aiohttp_socks/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def __init__(self, proxy_infos: Iterable[ProxyInfo], **kwargs):

self._proxy_infos = proxy_infos

self._streams = []

# noinspection PyMethodOverriding
async def _wrap_create_connection(self, protocol_factory, host, port, *, ssl, **kwargs):
proxies = []
Expand Down Expand Up @@ -152,6 +154,14 @@ async def _wrap_create_connection(self, protocol_factory, host, port, *, ssl, **
timeout=connect_timeout,
)

# Fix issue https://github.com/romis2012/aiohttp-socks/issues/27
# On Python 3.11.5
# We need to keep references to the stream.reader/stream.writer so that they
# are not garbage collected and closed while we're still using them.
# See StreamWriter.__del__ method (was added in Python 3.11.5)
self._streams.append(stream)
#

transport: BaseTransport = stream.writer.transport
protocol: ResponseHandler = protocol_factory()

Expand Down

0 comments on commit 7ad35e5

Please sign in to comment.