其他分享
首页 > 其他分享> > asyncio+aiohttp出现Exception ignored:RuntimeError('Event loop is closed')

asyncio+aiohttp出现Exception ignored:RuntimeError('Event loop is closed')

作者:互联网

一、报错信息

 1 Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001B11653EF70>
 2 Traceback (most recent call last):
 3   File "D:\Codes\SpiderProject\BingImageSpider\demo.py", line 16, in wrappers
 4     return func(self, *args, **kwargs)
 5   File "D:\DevTools\Python\lib\asyncio\proactor_events.py", line 116, in __del__
 6     self.close()
 7   File "D:\DevTools\Python\lib\asyncio\proactor_events.py", line 108, in close
 8     self._loop.call_soon(self._call_connection_lost, None)
 9   File "D:\DevTools\Python\lib\asyncio\base_events.py", line 746, in call_soon
10     self._check_closed()
11   File "D:\DevTools\Python\lib\asyncio\base_events.py", line 510, in _check_closed
12     raise RuntimeError('Event loop is closed')
13 RuntimeError: Event loop is closed

 

二、原因分析

像 aiohttp 这类第三方协程库都是依赖于标准库 asyncio 的,而 asyncio 对 Windows 的支持本来就不好。Python3.8 后默认 Windows 系统上的事件循环采用 ProactorEventLoop (仅用于 Windows )这篇文档描述了其在 Windows 下的缺陷:https://docs.python.org/zh-cn/3/library/asyncio-platforms.html#windows 

标签:__,ignored,Exception,run,aiohttp,self,closed,loop,asyncio
来源: https://www.cnblogs.com/ang0/p/16414402.html