MCPcopy Create free account
hub / github.com/0x676e67/wreq-python / async_non_session_get_test

Function async_non_session_get_test

benchmark/bench.py:103–125  ·  view source on GitHub ↗
(session_class, url, requests_number)

Source from the content-addressed store, hash-verified

101
102
103async def async_non_session_get_test(session_class, url, requests_number):
104 async def aget(s, url):
105 if session_class.__module__ == "aiohttp.client":
106 async with s.get(url) as resp:
107 return await resp.read()
108 if session_class.__name__ == "Client":
109 resp = await s.get(url)
110 return await resp.bytes()
111 else:
112 resp = await s.get(url)
113 return resp.text
114
115 for _ in range(requests_number):
116 try:
117 async with session_class() as s:
118 await aget(s, url)
119 except TypeError:
120 s = session_class()
121 await aget(s, url)
122 if hasattr(s, "aclose"):
123 await s.aclose()
124 elif hasattr(s, "close"):
125 s.close()
126
127
128def run_sync_tests(packages, url, requests_number):

Callers 1

run_async_testsFunction · 0.85

Calls 2

agetFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected