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
Nillouise
V2EX  ›  Python

Python 下还有实现 restart(common lisp 的 Condition System)特性的包吗?

  •  
  •   Nillouise · 2019-05-25 14:23:30 +08:00 · 1791 次点击
    这是一个创建于 1770 天前的主题,其中的信息可能已经有所发展或是发生改变。
    withrestart 跟 conditions 这两个包都已经用不了了。

    感觉 restart 这种异常处理机制比较适合爬虫的错误处理。
    4 条回复    2019-05-26 22:09:48 +08:00
    xiexingjia
        1
    xiexingjia  
       2019-05-25 14:35:42 +08:00
    tenacity 这种吗
    billgreen1
        2
    billgreen1  
       2019-05-25 21:52:49 +08:00
    tenacity 真是漂亮,优雅,pythonic
    rocketman13
        3
    rocketman13  
       2019-05-26 16:32:27 +08:00
    貌似有一个第三方模块 retry,发送错误自动重试
    Nillouise
        4
    Nillouise  
    OP
       2019-05-26 22:09:48 +08:00
    看了下 tenacity,retry,差很远呀,这个只是单纯的重试,而不是改良的错误处理机制。
    我需要的是抛出异常后,能继续执行下一句的库,比如
    try:
    a = 1/0
    print("also run to here")
    except:
    pass
    前一句抛出异常后,仍然能执行下一句的机制。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2923 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:10 · PVG 19:10 · LAX 04:10 · JFK 07:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.