Python aiohttp client
Project description
aiohttp client
What is the difference from aiohttp.Client?
It is simpler and as a Requests
Example:
Base reqeust:
import asyncio
from aio_clients import Http, Options
async def main():
r = await Http().get('http://google.com', o=Options(is_json=False, is_raw=True, is_close_session=True))
print(f'code={r.code} body={r.raw_body}')
asyncio.run(main())
Async reqeust
import asyncio
import aiohttp
from aio_clients import Http, Options
async def on_request_start(session, trace_config_ctx, params):
print("Starting request")
async def on_request_end(session, trace_config_ctx, params):
print("Ending request")
async def main():
trace_config = aiohttp.TraceConfig()
trace_config.on_request_start.append(on_request_start)
trace_config.on_request_end.append(on_request_end)
http = Http(
host='http://google.com/search?q=',
trace_config=trace_config
)
r = await asyncio.gather(
http.get('test', o=Options(is_json=False, is_raw=True)),
http.get('hello world', o=Options(is_json=False, is_raw=True)),
http.get('ping', o=Options(is_json=False, is_raw=True)),
)
print(f'status code={[i.code for i in r]}')
await http.close()
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aio-clients-0.1.0b7.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for aio_clients-0.1.0b7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab9e9af612e7839dda6fc99e9cb5ff5cb72dd127333cf7c3fd439e021b6db730 |
|
MD5 | 0ce670fed6e10335dfceb81fca39dc93 |
|
BLAKE2b-256 | 2d4eadc869411102524becfab9bd7c30eb7333d2e78951d07dcecb6a280c67ac |