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

Flask 取得的 API 消耗时间不准确

  •  
  •   frankyzf · Dec 14, 2023 · 2208 views
    This topic created in 1031 days ago, the information mentioned may be changed or developed.

    我是一个 python 方面的新手,在 Flask 框架下 log API 消耗时间时遇到一个问题,就是在十多个 API 中,有三四个 API 取得的时间不准确,而其他的 API 取得的时间是正常的。在 debug 时发现这些不准确的 API 遇到调用实际的 function 时没有走进去而直接到下一行,造成统计的时间比实际的短得多,只有 1 、2ms 。而其他正常的 API 没有这个问题,没看到这些 API 的写法有什么不一样。想问下各位大佬有遇到这个情况吗?先谢谢了。用的 vscode 。

    frankyzf
        1
    frankyzf  
    OP
       Dec 14, 2023
    哦,好像原因是生成器,方法里用 yield 返回的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2997 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 11:13 · PVG 19:13 · LAX 04:13 · JFK 07:13
    ♥ Do have faith in what you're doing.