我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用tornado.version_info()。
def __init__(self, handlers=None, default_host="", transforms=None, wsgi=False, middlewares=None, **settings): super(Application, self).__init__( handlers=handlers, default_host=default_host, transforms=transforms, wsgi=wsgi, **settings) self.middleware_fac = Manager() if middlewares: self.middleware_fac.register_all(middlewares) self.middleware_fac.run_init(self) if version_info[0] > 3: #?????4?????__call__()??????? this = self class HttpRequest(httputil.HTTPServerRequest): def __init__(self, *args, **kwargs): super(HttpRequest, self).__init__(*args, **kwargs) this.middleware_fac.set_request(self) try: this.middleware_fac.run_call(self) except Exception: SysLogger.trace_logger.error(traceback.format_exc()) httputil.HTTPServerRequest = HttpRequest
def __call__(self, request): if version_info[0] < 4: try: self.middleware_fac.set_request(request) self.middleware_fac.run_call(request) return web.Application.__call__(self, request) except Exception, e: SysLogger.trace_logger.error(e) raise