import aiohttp import asyncio async def aaa(): async with aiohttp.ClientSession() as session: async with session.get('https://github.com') as response: if response.status == 200: print('ok') loop = asyncio.get_event_loop() tasks = [aaa()] loop.run_until_complete(asyncio.wait(tasks))