一次tornado升级导致的bug,排查了好久,比较坑

在引入新项目时,原本稳定运行的代码因tornado升级到4.5出现错误。经过debug发现,新版本引入了tornado.routing模块,导致Application类的父类变化。虽然问题不在于代码本身,但这次升级带来的变动确实带来了不小困扰。
摘要由CSDN通过智能技术生成

之前一直稳定运行的代码,我引进新项目的时候,忽然报错

'Application' object has no attribute 'handlers'"

困扰许久。而且是时而正常,时而出错。


无法忍受,后开启debug模式排查,发现原来是tornado4.5起升级了,引入了新的tornado.routing模块。


4.4的Application代码如下:

class Application(httputil.HTTPServerConnectionDelegate):
    """A collection of request handlers that make up a web application.

    
    ``static_handler_class`` setting.

    """
    def __init__(self, handlers=None, default_host="", transforms=None,
                 **settings):
        if transforms is None:
            self.transforms = []
            if settings.get("compress_response") or settings.get("gzip"):
                self.transforms.append(GZipContentEncoding)
        else:
            self.transforms = transforms
        self.handlers = []
        self.named_handlers = {}
        self.default_host = default_host
        self.settings = settings
        self.ui_modules = {'linkify': _linkify,
                           'xsrf_form_html': _xsrf_form_html,
                           'Template': TemplateModule,
                           }
        self.ui_methods = {}
        self._load_ui_modules(settings.get("ui_modules", {}))
        self._load_ui_methods(settings.get("ui_methods", {}))
        if self.settings.get("static_path"):
            path = self.settings["static_path"]
            handlers = list(handlers or [])
            static_u
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值