import aiohttp
import asyncio
async def fetch(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
return await response.text()
async def main():
url = 'https://example.com'
# リクエストを非同期で開始
task = asyncio.create_task(fetch(url))
# ここで他の処理を行う
print("リクエスト送信後、他の処理を実行")
# リクエストの結果が必要な時点で結果を待つ
response = await task
print("レスポンス:", response)
# 非同期メイン関数を実行
asyncio.run(main())