推荐学习书目
› 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
woodfizky
V2EX  ›  Python

在依赖包里抛 SystemExit 应该怎么评价呢

  •  
  •   woodfizky · Dec 20, 2024 · 5361 views
    This topic created in 655 days ago, the information mentioned may be changed or developed.
    ttp 这个包,template text parser ,居然有遇到某种情况(比如取不到 attribute)直接抛 SystemExit 的操作。。

    起了一个 fastapi 作为解析服务,调用接口使用 ttp 进行解析的时候,直接把我服务干掉了,我都楞了好一会。

    甚至这种情况如果要写异常捕获,还得 except BaseException 或者裸 except 才奏效,因为 SystemExit 是一个直接继承 BaseException 的异常类,我写代码一般也只是捕获 Exception 而已,这我都觉得捕获的宽了。
    6 replies  •  2024-12-20 19:37:32 +08:00
    Sendya
        1
    Sendya  
       Dec 20, 2024
    哈哈哈 ,没见过
    h1298841903
        2
    h1298841903  
       Dec 20, 2024
    我遇到过更猛的人,之前我们公司接了一个 SDK ,到达某一时间戳后,APP 自动崩溃,打都打不开,这不是纯纯的病毒嘛。之后我们 QA 特意增加一个测试逻辑,把手机系统时间调整到几年后,看是否崩溃。
    jhdxr
        3
    jhdxr  
       Dec 20, 2024
    哈哈哈哈不要对写 Python 的代码水平有太高的预期
    48y1951r9G8k7Zou
        4
    48y1951r9G8k7Zou  
       Dec 20, 2024
    懂了,下次改成 os.abort()
    COW
        5
    COW  
       Dec 20, 2024 via Android
    利用了 Fail-fast 机制,在风险点出现第一时间关闭了进程,减少了产生潜在的严重故障的可能性,减少了潜在 issue 增长的可能性,提高了自己摸鱼的时间。😂
    NoOneNoBody
        6
    NoOneNoBody  
       Dec 20, 2024
    符合你的头像
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   730 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 20:59 · PVG 04:59 · LAX 13:59 · JFK 16:59
    ♥ Do have faith in what you're doing.