【问题标题】:Accidentally Interrupted cProfile意外中断的 cProfile
【发布时间】:2019-11-25 12:04:54
【问题描述】:

经过长时间的函数调用(16 小时),我提前用 KeyboardInterrupt 结束了它,但意外也中断了 cProfile,因为它需要很长时间才能响应。在 Debug Stackviewer 中,我遇到了这样的问题:

  • 键盘中断:
    • idlelib.run.runco​​de (...)
    • __ 主 __. (...)
    • cProfile.run (...)
    • profile.run (...)
    • profile._show (...)
    • cProfile.print_stats (...)
    • importlib._bootstrap._find_and_load (...)
    • importlib._bootstrap._find_and_load_unlocked (...)
    • importlib._bootstrap.find_spec (...)
    • importlib._bootstrap._get_spec (...)
    • importlib._bootstrap.find_spec (...)
    • importlib._bootstrap._path_stat (...)

有没有办法恢复 cProfile 打印的内容,有没有办法更巧妙地使用 cProfile 进行过长的函数调用。

【问题讨论】:

    标签: python recovery keyboardinterrupt


    【解决方案1】:

    不,当进程退出时,所有捕获的信息都丢失了。您可以考虑使用在程序运行时提供配置文件输出的profiling 包。我一直打算在我的一些交互式程序中使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-17
      • 1970-01-01
      • 2019-11-16
      • 2014-02-12
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多