AttributeError: 'StatusHandler' object has no attribute 'async_callback'

完整报错如下:

(Python3.6) appleyuchi@ubuntu19:5.2-使用Tornado进行长轮询$ python shopping_cart.py 
[I 200409 20:55:43 web:2162] 200 GET / (::1) 1.99ms
[I 200409 20:55:43 web:2162] 200 GET /static/images/internet.jpg (::1) 3.80ms
[I 200409 20:55:43 web:2162] 200 GET /static/scripts/inventory.js?v=081e5ab58d037c4cc17adb713e0b601b (::1) 0.66ms
[E 200409 20:55:43 web:1670] Uncaught exception GET /cart/status?session=a59525ab-ef55-4f2d-989a-90baea6d6578 (::1)
    HTTPServerRequest(protocol='http', host='localhost:8000', method='GET', uri='/cart/status?session=a59525ab-ef55-4f2d-989a-90baea6d6578', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "/home/appleyuchi/anaconda3/envs/Python3.6/lib/python3.6/site-packages/tornado/web.py", line 1548, in _stack_context_handle_exception
        raise_exc_info((type, value, traceback))
      File "<string>", line 4, in raise_exc_info
      File "/home/appleyuchi/anaconda3/envs/Python3.6/lib/python3.6/site-packages/tornado/web.py", line 1756, in wrapper
        result = method(self, *args, **kwargs)
      File "shopping_cart.py", line 64, in get
        self.application.shoppingCart.register(self.async_callback(self.on_message))
    AttributeError: 'StatusHandler' object has no attribute 'async_callback'

故障原因:

代码一般出自Tornado2.x

解决方案:

self.application.shoppingCart.register(self.async_callback(self.on_message))

改成:

self.application.shoppingCart.register(callback=self.on_message)


 

发布了824 篇原创文章 · 获赞 394 · 访问量 175万+

猜你喜欢

转载自blog.csdn.net/appleyuchi/article/details/105419814
今日推荐