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

@@ -15,13 +15,8 @@ class TestApiClient(unittest.TestCase):
async def test_context_manager_closes_client(self):
async with petstore_api.ApiClient() as client:
# thread pool
self.assertIsNotNone(client.pool)
pool_ref = weakref.ref(client._pool)
self.assertIsNotNone(pool_ref())
# pool_manager
self.assertFalse(client.rest_client.pool_manager.closed)
rest_pool_ref = client.rest_client.pool_manager
self.assertIsNone(pool_ref())
self.assertTrue(rest_pool_ref.closed)

View File

@@ -11,7 +11,8 @@ def id_gen(bits=32):
def async_test(f):
def wrapper(*args, **kwargs):
coro = asyncio.coroutine(f)
# coro = asyncio.coroutine(f)
coro = f
future = coro(*args, **kwargs)
loop = asyncio.get_event_loop()
loop.run_until_complete(future)