Skip to content

Python

https://www.python.org/

Python is a programming language that lets you work quickly and integrate systems more effectively.

Use aiohttp and asyncio to run I/O coroutines concurrently

Section titled “Use aiohttp and asyncio to run I/O coroutines concurrently”

Example:

import aiohttp
import asyncio
async def get_9():
async with aiohttp.ClientSession() as session:
async with session.get('https://httpbin.org/delay/9') as response:
await response.text()
print("9 finished")
async def get_3():
async with aiohttp.ClientSession() as session:
async with session.get('https://httpbin.org/delay/3') as response:
await response.text()
print("3 finished")
async def main():
await asyncio.gather(get_9(), get_3())
asyncio.run(main())

Pasted image 20250408170748.png