【问题标题】:Possible to print the IPDB/Celery-RDB stack trace ('where') to stdout from within the code?可以从代码中将 IPDB/Celery-RDB 堆栈跟踪('where')打印到标准输出吗?
【发布时间】:2018-08-20 01:44:20
【问题描述】:

在 IPDB 或 RDB 中输入 'w(here)' 将打印出堆栈跟踪。

有没有办法在不输入set_trace() 的情况下做到这一点?

我想我想像print(w) 之类的东西,或者只是在我set_trace() 的位置打印堆栈跟踪。

【问题讨论】:

  • 你的意思是traceback.print_stack?
  • @georgexsh 这个怎么用?你的意思是traceback.print_exc
  • @georgexsh 是的,正是我想要的。谢谢。如果您发布,将接受答案。

标签: python python-3.x debugging celery ipdb


【解决方案1】:

traceback.print_stack() 是你想要的,它将打印从sys._getframe() 开始的当前调用堆栈,请参阅its doc 的更多信息。

【讨论】:

    猜你喜欢
    • 2012-09-05
    • 1970-01-01
    • 1970-01-01
    • 2015-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    相关资源
    最近更新 更多