FILE "\ASYNCIO\EVENTS.PY", LINE 501, IN ADD_READER RAISE NOTIMPLEMENTEDERROR 报错解决

"D: \ PYTHON38 \ LIB \ ASYNCIO \ EVENTS.PY", LINE 501, IN ADD_READER RAISE NOTIMPLEMENTEDERROR NOTIMPLEMENTEDERROR error resolved

PYTHON3 occur when using the framework for TORNADO

Questions are as follows

Traceback (most recent call last):
  File "D:/python38_pycharm/web_server_tornado.py", line 45, in <module>
    http_server.add_sockets(sockets)
  File "D:\python38_pycharm\venv\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
    self._handlers[sock.fileno()] = add_accept_handler(
  File "D:\python38_pycharm\venv\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
    io_loop.add_handler(sock, accept_handler, IOLoop.READ)
  File "D:\python38_pycharm\venv\lib\site-packages\tornado\platform\asyncio.py", line 99, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "D:\Python38\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

Here Insert Picture Description

Solution:

Find tornado / platform / asyncio.py modify the file, add the code as follows:

import sys

if sys.platform == 'win32':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

Guess you like

Origin www.cnblogs.com/shanghongyun/p/12118096.html