-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fs.http: prevent hangs under some network conditions #7460
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,11 +81,20 @@ def _prepare_credentials(self, **config): | |
f"Auth method {auth_method!r} is not supported." | ||
) | ||
|
||
# Force cleanup of closed SSL transports. | ||
# https://github.com/iterative/dvc/issues/7414 | ||
connector_kwargs = {"enable_cleanup_closed": True} | ||
|
||
if "ssl_verify" in config: | ||
with fsspec_loop(): | ||
client_kwargs["connector"] = aiohttp.TCPConnector( | ||
ssl=make_context(config["ssl_verify"]) | ||
) | ||
connector_kwargs.update(ssl=make_context(config["ssl_verify"])) | ||
|
||
with fsspec_loop(): | ||
client_kwargs["connector"] = aiohttp.TCPConnector( | ||
**connector_kwargs | ||
) | ||
# The connector should not be owned by aiohttp.ClientSession since | ||
# it is closed by fsspec (HTTPFileSystem.close_session) | ||
client_kwargs["connector_owner"] = False | ||
|
||
# Allow reading proxy configurations from the environment. | ||
client_kwargs["trust_env"] = True | ||
|
@@ -114,7 +123,7 @@ async def get_client(self, **kwargs): | |
total=None, | ||
connect=self.REQUEST_TIMEOUT, | ||
sock_connect=self.REQUEST_TIMEOUT, | ||
sock_read=None, | ||
sock_read=self.REQUEST_TIMEOUT, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am curious to see if only this will solve the problem in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've tried, it solves the issues on my machine ™️ (MacOS) but it still freezes on the |
||
) | ||
|
||
return RetryClient(**kwargs) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming that setting the
sock_read=self.REQUEST_TIMEOUT
(60s) will not create any issues: the default buffer size is 2**16,See
ClientSession._request
:https://github.com/aio-libs/aiohttp/blob/f5ff95efe278c470a2ff65cabbb5f5f08ba07416/aiohttp/client.py#L511-L519
https://github.com/aio-libs/aiohttp/blob/f5ff95efe278c470a2ff65cabbb5f5f08ba07416/aiohttp/client_proto.py#L17
https://github.com/aio-libs/aiohttp/blob/f5ff95efe278c470a2ff65cabbb5f5f08ba07416/aiohttp/streams.py#L111