今天拉了一个使用了tornado
的项目在本地跑,按照源码作者的步骤配置完,运行,直接报错了,要求环境Python3.6+
,我装的是Python3.8
,理论上应该直接正常运行的,报错信息:
Traceback (most recent call last):
File "ice_server.py", line 150, in <module>
RunServer.run_server(port=p, host=h)
File "ice_server.py", line 125, in run_server
tornado_server.start()
File "D:\PycharmProjects\ice\venv\lib\site-packages\tornado\tcpserver.py", line 244, in start
self.add_sockets(sockets)
File "D:\PycharmProjects\ice\venv\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
self._handlers[sock.fileno()] = add_accept_handler(
File "D:\PycharmProjects\ice\venv\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
io_loop.add_handler(sock, accept_handler, IOLoop.READ)
File "D:\PycharmProjects\ice\venv\lib\site-packages\tornado\platform\asyncio.py", line 100, in add_handler
self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
File "C:\Users\huan\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py", line 501, in add_reader
raise NotImplementedError
NotImplementedError
一番谷歌原来对于这个问题tornado
的参与者们已经收到了很多反馈,有个回复里这么说:
Python 3.8 asyncio is going to make the "proactor" event loop the default, instead of the current "selector" event loop. This is a problem for Tornado because the proactor event loop doesn't support the unix-style add_reader APIs that Tornado uses.
Anyone using Tornado 5+ on windows with python 3.8 will need to configure asyncio to use the selector event loop; we'll have to document this. We should also try to detect the use of a proactor event loop and give a clear error message
大概意思Python3.8
的asyncio
改变了循环方式,因为这种方式在windows上不支持相应的add_reader APIs
,就会抛出NotImplementedError
错误。
解决办法
找到这个项目使用的python环境的lib\site-packages
,做下面的修改,在path-to-python\lib\site-packages\tornado\platform\asyncio.py
开头添加代码:
import sys if sys.platform == 'win32': asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
这样就可以正常运行了。
总结
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 蔡依林《MYSELF》 奢华庆菌版 2CD[WAV+CUE][1.5G]
- 刘春美《心与心寻世界名曲中文版》新京文[低速原抓WAV+CUE]
- 朱逢博《蔷薇蔷薇处处开》[FLAC+CUE]
- 姚璎格2005《心在哭泣》龙韵[WAV分轨]
- 费玉清《费玉清收藏》 2CD 华纳[WAV+CUE][1G]
- 徐怀钰《LOVE》台湾首版[WAV+CUE][1G]
- 群星《英皇精挑细选Vol.1》[WAV+CUE][1G]
- 郑钧.2007-长安长安【灯火文化】【WAV+CUE】
- 袁小迪向蕙玲.2005-纯情红玫瑰【全员集合】【WAV+CUE】
- 周华健.2015-水浒三部曲原创音乐选辑【滚石】【FLAC分轨】
- 钟志刚《为爱而歌DSD》[WAV+CUE]
- 孙露《情人的眼泪》[低速原抓WAV+CUE]
- 【雨果唱片】刘明源《胡琴专辑》1993[WAV+CUE]
- 黄莺莺《25周年纪念金曲专辑》[WAV+CUE][1.1G]
- 刘德丽《刘德丽新曲+精选》2023[WAV+CUE][1G]