import asyncio import aiohttp url_req ='https://www.prevision-meteo.ch/services/json/' async def get_temp(city:str): """Get the temperature of the city given in params""" print(f"Request for {city}.") s = time.perf_counter() async with aiohttp.ClientSession() as session: async with session.get(url=url_req+city.lower()) as r: temp = await r.json() elapsed = time.perf_counter() - s print(f"Response is now ready {elapsed:0.2f} seconds.\nTemperature at {city} : {temp.get('current_condition')['tmp']} C.") async def main(): await asyncio.gather(get_temp('Paris'),get_temp('Toulouse'),get_temp('Marseille')) if __name__ == "__main__": import time s = time.perf_counter() asyncio.run(main()) elapsed = time.perf_counter() - s print(f"Program executed in {elapsed:0.2f} seconds.")