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
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)

 

你可能感兴趣的:(tornado,python基础知识,tornado,websocket)