pytho3.8 tornado报错NotImplementedError

报错:NotImplementedError

iso(unix)和linux系统执行代码不会报错,但代码在windows执行就会报错:NotImplementedError具体内容:

Traceback (most recent call last):
  File "D:\project\src\base\util.py", line 560, in http_request
    resp = await http_client.fetch(url, method=method, raise_error=False, **settings)
  File "D:\project\venv\lib\site-packages\tornado\simple_httpclient.py", line 330, in run
    stream = await self.tcp_client.connect(
  File "D:\project\venv\lib\site-packages\tornado\tcpclient.py", line 280, in connect
    af, addr, stream = await connector.start(connect_timeout=timeout)
  File "D:\project\venv\lib\site-packages\tornado\tcpclient.py", line 110, in start
    self.try_connect(iter(self.primary_addrs))
  File "D:\project\venv\lib\site-packages\tornado\tcpclient.py", line 128, in try_connect
    stream, future = self.connect(af, addr)
  File "D:\project\venv\lib\site-packages\tornado\tcpclient.py", line 334, in _create_stream
    return stream, stream.connect(addr)
  File "D:\project\venv\lib\site-packages\tornado\iostream.py", line 1219, in connect
    self._add_io_state(self.io_loop.WRITE)
  File "D:\project\venv\lib\site-packages\tornado\iostream.py", line 1050, in _add_io_state
    self.io_loop.add_handler(self.fileno(), self._handle_events, self._state)
  File "D:\project\venv\lib\site-packages\tornado\platform\asyncio.py", line 102, in add_handler
    self.asyncio_loop.add_writer(fd, self._handle_events, fd, IOLoop.WRITE)
  File "D:\anaconda\lib\asyncio\events.py", line 507, in add_writer
    raise NotImplementedError
NotImplementedError

解决方案:

在执行文件开始预先执行一下代码:

import platform
if platform.system() == "Windows":
    import asyncio
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

你可能感兴趣的:(报错,tornado,python)