python: remove non-async code path from the aiohttp generator (#16601)

* python: remove non-async code path from the aiohttp generator

This removes all the non-async code from the aiohttp generator:

* all the methods that should be asynchronous are marked as `async`
* the `async_req` parameter is gone; calls are directly awaitables now
* the async calls into a thread pool are gone and the thread pool is
  gone too (now useless)

Closes: #15824
Closes: #5539
Related: #763
Related: #3696

* Fix empty line

* remove more
This commit is contained in:
Jonathan Ballet
2023-09-20 04:48:31 +02:00
committed by GitHub
parent 69bc994ba7
commit a2f6b8eae5
14 changed files with 341 additions and 1513 deletions

View File

@@ -223,7 +223,7 @@ class ApiClient:
self.last_response = response_data
return_data = None # assuming derialization is not needed
return_data = None # assuming deserialization is not needed
# data needs deserialization or returns HTTP data (deserialized) only
if _preload_content or _return_http_data_only:
response_type = response_types_map.get(str(response_data.status), None)
@@ -406,27 +406,28 @@ class ApiClient:
If parameter async_req is False or missing,
then the method will return the response directly.
"""
args = (
resource_path,
method,
path_params,
query_params,
header_params,
body,
post_params,
files,
response_types_map,
auth_settings,
_return_http_data_only,
collection_formats,
_preload_content,
_request_timeout,
_host,
_request_auth,
)
if not async_req:
return self.__call_api(resource_path, method,
path_params, query_params, header_params,
body, post_params, files,
response_types_map, auth_settings,
_return_http_data_only, collection_formats,
_preload_content, _request_timeout, _host,
_request_auth)
return self.__call_api(*args)
return self.pool.apply_async(self.__call_api, (resource_path,
method, path_params,
query_params,
header_params, body,
post_params, files,
response_types_map,
auth_settings,
_return_http_data_only,
collection_formats,
_preload_content,
_request_timeout,
_host, _request_auth))
return self.pool.apply_async(self.__call_api, args)
def request(self, method, url, query_params=None, headers=None,
post_params=None, body=None, _preload_content=True,