python3.9.6 异步编程的坑 RuntimeError: Event loop is closed

import aiohttp
import asyncio
async def fetch(session, url):
    print("发送请求:", url)
    async with session.get(url, verify_ssl=False) as response:
        text = await response.text()
        print("得到结果:", url, len(text))
async def main():
    async with aiohttp.ClientSession() as session:
        url_list = [
            'http://python.org',
            'http://www.baidu.com',
            'http://www.pythonav.com'
        ]
        tasks = [asyncio.create_task(fetch(session, url)) for url in url_list]
        await asyncio.wait(tasks)
if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

以上代码在python3.8和3.9均执行成功

import aiohttp
import asyncio
async def fetch(session, url):
    print("发送请求:", url)
    async with session.get(url, verify_ssl=False) as response:
        text = await response.text()
        print("得到结果:", url, len(text))
async def main():
    async with aiohttp.ClientSession() as session:
        url_list = [
            'http://python.org',
            'http://www.baidu.com',
            'http://www.pythonav.com'
        ]
        tasks = [asyncio.create_task(fetch(session, url)) for url in url_list]
        await asyncio.wait(tasks)
if __name__ == '__main__':
    asyncio.run(main())

这段代码在python3.8执行成功,3.9提示RuntimeError: Event loop is closed。

为何不行我也不是很清楚,搞明白了再来更新!