当前位置: 首页>>代码示例>>Python>>正文


Python web.Finish方法代码示例

本文整理汇总了Python中tornado.web.Finish方法的典型用法代码示例。如果您正苦于以下问题:Python web.Finish方法的具体用法?Python web.Finish怎么用?Python web.Finish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.web的用法示例。


在下文中一共展示了web.Finish方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import Finish [as 别名]
def get(self):
            self.set_status(401)
            self.set_header('WWW-Authenticate', 'Basic realm="something"')
            if self.get_argument('finish_value', ''):
                raise Finish('authentication required')
            else:
                self.write('authentication required')
                raise Finish() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:10,代码来源:web_test.py

示例2: cursor

# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import Finish [as 别名]
def cursor(self):
        cursor = self.get_argument('cursor', None)
        if cursor:
            try:
                cursor = int(cursor)
            except ValueError:
                self.redirect(self.request.path, permanent=True)
                raise Finish()
            if cursor < 0:
                raise HTTPError(404)
        else:
            cursor = None
        return cursor 
开发者ID:keakon,项目名称:Doodle,代码行数:15,代码来源:base_handler.py

示例3: emit

# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import Finish [as 别名]
def emit(self, data):
        """Emit an eventstream event"""
        if type(data) is not str:
            serialized_data = json.dumps(data)
        else:
            serialized_data = data
        try:
            self.write('data: {}\n\n'.format(serialized_data))
            await self.flush()
        except StreamClosedError:
            app_log.warning("Stream closed while handling %s", self.request.uri)
            # raise Finish to halt the handler
            raise Finish() 
开发者ID:jupyterhub,项目名称:binderhub,代码行数:15,代码来源:builder.py

示例4: call

# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import Finish [as 别名]
def call(self, module, method, wrapped, instance, args, kwargs):
        if not hasattr(instance.application, "elasticapm_client"):
            # If tornado was instrumented but not as the main framework
            # (i.e. in Flower), we should skip it.
            return wrapped(*args, **kwargs)

        # Late import to avoid ImportErrors
        from tornado.web import Finish, HTTPError
        from elasticapm.contrib.tornado.utils import get_data_from_request

        e = args[0]
        if isinstance(e, Finish):
            # Not an error; Finish is an exception that ends a request without an error response
            return wrapped(*args, **kwargs)

        client = instance.application.elasticapm_client
        request = instance.request
        client.capture_exception(
            context={"request": get_data_from_request(instance, request, client.config, constants.ERROR)}
        )
        if isinstance(e, HTTPError):
            elasticapm.set_transaction_result("HTTP {}xx".format(int(e.status_code / 100)), override=False)
            elasticapm.set_context({"status_code": e.status_code}, "response")
        else:
            elasticapm.set_transaction_result("HTTP 5xx", override=False)
            elasticapm.set_context({"status_code": 500}, "response")

        return wrapped(*args, **kwargs) 
开发者ID:elastic,项目名称:apm-agent-python,代码行数:30,代码来源:tornado.py

示例5: _raise_auth_required

# 需要导入模块: from tornado import web [as 别名]
# 或者: from tornado.web import Finish [as 别名]
def _raise_auth_required(self):
        from tornado import web
        self.set_status(401)
        self.write("Authentication required")
        self.set_header("WWW-Authenticate", "Negotiate")
        raise web.Finish() 
开发者ID:jcrist,项目名称:skein,代码行数:8,代码来源:tornado.py


注:本文中的tornado.web.Finish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。