Python tornado.web 模块,Finish() 实例源码

我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用tornado.web.Finish()

项目:TelegramRelay    作者:cjhgo    | 项目源码 | 文件源码
def _handle_request_exception(self, e):
        if isinstance(e, Finish):
            # Not an error; just finish the request without logging.
            if not self._finished:
                self.finish(*e.args)
            return
        try:
            self.log_exception(*sys.exc_info())
        except Exception:
            app_log.error("Error in exception logger", exc_info=True)
        if self._finished:
            return
        if isinstance(e, HTTPError):
            self.response(e)
        else:
            self.response(HTTPError(log_message=repr(e)))
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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()
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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()
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
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()
项目:My-Web-Server-Framework-With-Python2.7    作者:syjsu    | 项目源码 | 文件源码
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()
项目:binderhub    作者:jupyterhub    | 项目源码 | 文件源码
def emit(self, data):
        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 web.Finish()
项目:annotated-py-tornado    作者:hhstore    | 项目源码 | 文件源码
def get(self):
            self.set_status(401)
            self.set_header('WWW-Authenticate', 'Basic realm="something"')
            self.write('authentication required')
            raise Finish()
项目:annotated-py-tornado    作者:hhstore    | 项目源码 | 文件源码
def get(self):
            self.set_status(401)
            self.set_header('WWW-Authenticate', 'Basic realm="something"')
            self.write('authentication required')
            raise Finish()
项目:Doodle    作者:keakon    | 项目源码 | 文件源码
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
项目:params    作者:reorx    | 项目源码 | 文件源码
def _handle_request_exception(self, e):
        from tornado.web import Finish, app_log, gen_log, HTTPError, httputil

        if isinstance(e, Finish):
            # Not an error; just finish the request without logging.
            if not self._finished:
                self.finish(*e.args)
            return

        ## add
        if isinstance(e, params.InvalidParams):
            self.set_status(400)
            self.finish({'error': str(e)})
            return
        ## end

        try:
            self.log_exception(*sys.exc_info())
        except Exception:
            # An error here should still get a best-effort send_error()
            # to avoid leaking the connection.
            app_log.error("Error in exception logger", exc_info=True)
        if self._finished:
            # Extra errors after the request has been finished should
            # be logged, but there is no reason to continue to try and
            # send a response.
            return
        if isinstance(e, HTTPError):
            if e.status_code not in httputil.responses and not e.reason:
                gen_log.error("Bad HTTP status code: %d", e.status_code)
                self.send_error(500, exc_info=sys.exc_info())
            else:
                self.send_error(e.status_code, exc_info=sys.exc_info())
        else:
            self.send_error(500, exc_info=sys.exc_info())
项目:projects-2017-2    作者:ncss    | 项目源码 | 文件源码
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()
项目:aweasome_learning    作者:Knight-ZXW    | 项目源码 | 文件源码
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()
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
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()
项目:browser_vuln_check    作者:lcatro    | 项目源码 | 文件源码
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()
项目:PyQYT    作者:collinsctk    | 项目源码 | 文件源码
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()
项目:ProgrameFacil    作者:Gpzim98    | 项目源码 | 文件源码
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()
项目:ProgrameFacil    作者:Gpzim98    | 项目源码 | 文件源码
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()