V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yueyoum
V2EX  ›  Python

大伙有什么自己实现的好玩的WSGI Middleware

  •  
  •   yueyoum ·
    yueyoum · 2013-06-09 16:08:38 +08:00 · 2840 次点击
    这是一个创建于 3967 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我做的一个项目基于 bottle + gunicorn 都是遵循标准的 WSGI规范。

    现在遇到个需求,就是监控web 是否出错,一旦出错就电子邮件通知。


    于是用了一个上午 做了一个这样的middleware,
    https://github.com/yueyoum/smoke

    在使用的时候, 只要你继承 smoke.exceptions.ExceptionMiddleware,重写 handle_exception方法即可。 此方法有个两个位置参数,第一个是 traceback.format_ext(), 第二个是 sys.exc_info()


    带有一个例子, 当然在例子里也说明了, 生成环境中不要直接发邮件,应该用消息队列,或者简单的用redis做队列
    2 条回复    1970-01-01 08:00:00 +08:00
    kebot
        1
    kebot  
       2013-06-09 21:57:00 +08:00
    自己没做过,不过wdb挺好的。就是一个debug,很牛逼的
    whtsky
        2
    whtsky  
       2013-06-09 23:07:21 +08:00 via iPhone
    为什么不用 Sentry
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2832 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:23 · PVG 22:23 · LAX 07:23 · JFK 10:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.