- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个简约的 Tornado 应用程序:
import tornado.ioloop
import tornado.web
class PingHandler(tornado.web.RequestHandler):
def get(self):
self.write("pong\n")
if __name__ == "__main__":
application = tornado.web.Application([ ("/ping", PingHandler), ])
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Tornado 不断向 stderr 报告错误请求:
WARNING:tornado.access:404 GET / (127.0.0.1) 0.79ms
问题:它想阻止它记录错误信息。怎么办?
Tornado 版本 3.1; Python 2.6
最佳答案
很明显,当我们启动 Tornado 时,“某人”正在初始化日志子系统。以下是来自 ioloop.py
的代码揭示了其中的奥秘:
def start(self):
if not logging.getLogger().handlers:
# The IOLoop catches and logs exceptions, so it's
# important that log output be visible. However, python's
# default behavior for non-root loggers (prior to python
# 3.2) is to print an unhelpful "no handlers could be
# found" message rather than the actual log entry, so we
# must explicitly configure logging if we've made it this
# far without anything.
logging.basicConfig()
basicConfig
被调用并配置默认的 stderr
处理程序。
因此,要为 tonado 访问设置正确的日志记录,您需要:
将处理程序添加到 tornado.access
记录器:logging.getLogger("tornado.access").addHandler(...)
禁用上述记录器的传播:logging.getLogger("tornado.access").propagate = False
。否则消息将同时到达您的处理程序和 stderr
关于Python Tornado - 禁用日志记录到 stderr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21234772/
根据一些谷歌搜索,我安装了以下错误处理程序。然而,似乎返回 http 500 的 python 异常并没有被这些东西捕获,尽管 404 是这样。通过我在下面的代码中留下的打印语句,我可以看到它没有命中
我刚刚意识到 WebSocketHandler.write_message() 返回一个 Future。我以前没有在我的函数中产生过这个函数: @tornado.gen.coroutine
这是我的 Tornado 文件:: from tornado.wsgi import WSGIContainer from tornado.ioloop import IOLoop from torn
class MainHandler(BaseHandler): @tornado.web.authenticated def get(self): self.rende
我正在尝试使用 AsyncHTTPTestCase 测试 Tornado .我想测试标有 @tornado.web.authenticated 注释的处理程序。因为此处理程序需要身份验证,所以我们必须
我正在使用 Tornado Web Server (版本 4.1)使用 Python 2.7 创建 REST Web 应用程序。我的请求处理程序之一 (web.RequestHandler) 使用多部
我想知道tornado 的内部工作流程,并且看过this article ,很好,但我就是想不通 ioloop.py里面有这样一个函数 def add_handler(self, fd, handle
如何遍历从 Python/Tornado 处理程序传递到 Tornado 模板的字典? 我试过 {% for key, value in statistics %}
我有一个 Tornado 后端,为 Angular 前端提供服务。更新数据库时,tornado api 不会获取更新的数据。它仅在我重新启动服务器后出现。有人可以帮我解决这个问题吗?我希望获取的数据能
我尝试使用自定义的 WSGIContainer 来处理异步操作: from tornado import httpserver, httpclient, ioloop, wsgi, gen @gen.
from tornado.web import RequestHandler class HelloWorldHandler(RequestHandler): def get(self):
Pylint 遇到 @tornado.web.authenticated 时崩溃 class Handler1(tornado.web.RequestHandler): def get(sel
经过 tornado.gen documentation有人可以帮我理解 tornado.gen.coroutine 和 tornado.gen.engine 之间的确切区别 最佳答案 正如 gen.
代码如下: from tornadoredis import Client from tornado.ioloop import IOLoop from tornado.gen import coro
我有一个 tornado.websocket.WebSocketHandler 的子类。在该类中,我有一个方法使用 Django ORM 从子类模型中获取用户:django.contrib.auth.
我是 ssl 之类的新手,我已经使用 openssl 生成了自签名证书。 openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days
我已经从 tornado 4.2 移动到 tornado 6.0.3,我得到了错误 AttributeError:模块“tornado.web”没有属性“异步” 根据 tornado v6 seems
我一直在关注此 ( https://developer.ibm.com/tutorials/se-distributed-apps-zeromq-part2/) 教程,以设置使用 CurveZMQ 加
我在使用tornado-celery整合tornado和celery时,出现错误:``` traceback (most recent call last): File "/usr/local/l
我正在使用 Tornado 与 twitter 等第三方进行身份验证。 我的登录处理程序看起来像这样 class AuthLoginHandler(BaseHandler, tornado.auth.
我是一名优秀的程序员,十分优秀!