fune/third_party/python/aiohttp/examples/client_json.py
Connor Sheehan fcfe38a1ef Bug 1854496: update vendored aiohttp/requests and add new dependencies r=firefox-build-system-reviewers,mach-reviewers,ahochheiden
Update `aiohttp` to version 3.8.5 and `requests` to version 2.31.0,
and vendor their respective dependencies. Add all the new dependencies
to the various required site virtualenv requirements files.

Differential Revision: https://phabricator.services.mozilla.com/D188904
2023-09-25 14:22:11 +00:00

22 lines
489 B
Python
Executable file

#!/usr/bin/env python3
import asyncio
import aiohttp
async def fetch(session: aiohttp.ClientSession) -> None:
print("Query http://httpbin.org/get")
async with session.get("http://httpbin.org/get") as resp:
print(resp.status)
data = await resp.json()
print(data)
async def go(loop):
async with aiohttp.ClientSession(loop=loop) as session:
await fetch(session)
loop = asyncio.get_event_loop()
loop.run_until_complete(go(loop))
loop.close()