當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。