From 0b92bfdf80ab40787072d546b6962c77dd24e0b7 Mon Sep 17 00:00:00 2001 From: Matthias Kesler Date: Thu, 2 May 2024 13:04:17 +0200 Subject: [PATCH] Fix #66194: Exchange HTTPClient by AsyncHTTPClient in salt.utils.http --- changelog/66330.fixed.md | 1 + salt/utils/http.py | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 changelog/66330.fixed.md diff --git a/changelog/66330.fixed.md b/changelog/66330.fixed.md new file mode 100644 index 00000000000..25d7caf9923 --- /dev/null +++ b/changelog/66330.fixed.md @@ -0,0 +1 @@ +fix #66194: Exchange HTTPClient by AsyncHTTPClient in salt.utils.http diff --git a/salt/utils/http.py b/salt/utils/http.py index 4d6c53faf6e..67fc05ce469 100644 --- a/salt/utils/http.py +++ b/salt/utils/http.py @@ -25,7 +25,7 @@ import zlib import tornado.httpclient import tornado.httputil import tornado.simple_httpclient -from tornado.httpclient import HTTPClient +from tornado.httpclient import AsyncHTTPClient import salt.config import salt.loader @@ -43,6 +43,7 @@ import salt.utils.xmlutil as xml import salt.utils.yaml import salt.version from salt.template import compile_template +from salt.utils.asynchronous import SyncWrapper from salt.utils.decorators.jinja import jinja_filter try: @@ -598,7 +599,7 @@ def query( salt.config.DEFAULT_MINION_OPTS["http_request_timeout"], ) - tornado.httpclient.AsyncHTTPClient.configure(None) + AsyncHTTPClient.configure(None) client_argspec = salt.utils.args.get_function_argspec( tornado.simple_httpclient.SimpleAsyncHTTPClient.initialize ) @@ -629,10 +630,10 @@ def query( req_kwargs = salt.utils.data.decode(req_kwargs, to_str=True) try: - download_client = ( - HTTPClient(max_body_size=max_body) - if supports_max_body_size - else HTTPClient() + download_client = SyncWrapper( + AsyncHTTPClient, + kwargs={"max_body_size": max_body} if supports_max_body_size else {}, + async_methods=["fetch"], ) result = download_client.fetch(url_full, **req_kwargs) except tornado.httpclient.HTTPError as exc: