tornado websocket启动时报错:“ assert len(rule) in (2, 3, 4) AssertionError”,错误原因

在handlers这个路由列表后面添加了一个逗号“,”, 引起这个错误,去掉即可。

报错信息如下: 

C:\python3\python3.exe Z:/Code/python/tvshow/socket_server.py
2019-03-14 11:27:36,253 - LZ - DEBUG - 初始化统计数据中......
0.01 (1): SELECT * FROM business
http://127.0.0.1:80/back/multiple_org_print_service_config/1
0.02 (2): SELECT * FROM window
0.0 (3): SELECT id FROM organization
http://127.0.0.1:80/back/multiple_org_print_service_config/2
http://127.0.0.1:80/back/multiple_org_print_service_config/3
2019-03-14 11:27:37,290 - LZ - DEBUG - 窗口配置初始化成功......
2019-03-14 11:27:37,292 - LZ - DEBUG - 初始化完成......
2019-03-14 11:27:37,301 - LZ - DEBUG - 定时更新任务已经启动..........
Traceback (most recent call last):
  File "Z:/Code/python/tvshow/socket_server.py", line 119, in <module>
2019-03-14 11:27:37,302 - LZ - DEBUG - udp listener port:9999
    ws_app = Application()
  File "Z:/Code/python/tvshow/socket_server.py", line 106, in __init__
    tornado.web.Application.__init__(self, handlers, **settings)
  File "C:\python3\lib\site-packages\tornado\web.py", line 1911, in __init__
    self.wildcard_router = _ApplicationRouter(self, handlers)
  File "C:\python3\lib\site-packages\tornado\web.py", line 1786, in __init__
    super(_ApplicationRouter, self).__init__(rules)
  File "C:\python3\lib\site-packages\tornado\routing.py", line 363, in __init__
    super(ReversibleRuleRouter, self).__init__(rules)
  File "C:\python3\lib\site-packages\tornado\routing.py", line 288, in __init__
    self.add_rules(rules)
  File "C:\python3\lib\site-packages\tornado\routing.py", line 298, in add_rules
    assert len(rule) in (2, 3, 4)
AssertionError

 


class Application(tornado.web.Application):
    def __init__(self):
        handlers = [
            (r"/back/statistics", Statistics),
            (r"/back/estate/hall/led/a", LED_A),
            (r"/back/estate/hall/led/b", LED_B),
            (r"/back/estate/hall/mi/a", MI_A),
            (r"/back/estate_hall/mi/b", MI_B),
            (r"/(.*)", tornado.web.StaticFileHandler, {'path': 'static'}),
        ],  # 去掉这里的","

        settings = {
            'template_path': 'templates',
            'static_path': os.path.join(os.path.dirname(__file__), "./"),
        }
        tornado.web.Application.__init__(self, handlers, **settings)

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值