Skip to content

测试tornado出错 #9

Description

@dingliumath

您好!我最近购买了您的爬虫书籍,按照所提供的流程配置环境。但是,在测试tornado时出现错误(排除安装过程出问题,因为import tornado没有问题)。我的系统是Win10+python3.7.7(通过anaconda安装)+tornado6.0.4,具体来说,在运行以下例子(书籍p.43):

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")

def make_app():
return tornado.web.Application([
(r"/", MainHandler),
])

if name == "main":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()

要么没有反应,如下:
image-20200421103220795

要么在jupyter notebook里面提醒
RuntimeError: This event loop is already running

我在网上搜索了好久,有说老版本能够解决问题(我试了,python提醒老版本不兼容),有说添加import nest_asyncio
nest_asyncio.apply()
没有解决问题,我也试了,此时出现新的错误:
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted

请问应该如何解决这个问题呢?谢谢!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions