Files
livecampus_mcs_p_2027_2/Semaine_09/Asyncio_examples/misc.py
T
2026-08-04 16:42:35 +02:00

26 lines
547 B
Python

"""
async for
async with
"""
import asyncio, aiohttp
async def check(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
print(f"{url} : status => {response.status}")
async def puissance2(stop= 10):
exponent = 0
while exponent < stop:
yield 2 ** exponent
exponent += 1
await asyncio.sleep(0.2)
async def main():
liste = []
async for i in puissance2():
liste.append(i)
print(liste)
liste = [j async for j in puissance2()]