python: How to trace function execution order in large project

前端 未结 2 1336
小蘑菇
小蘑菇 2021-02-06 03:17

I want to trace function/class executive order in scrapy framework. There are multiple *.py files across the default project, and I want to know which py file and class has been

2条回答
  •  独厮守ぢ
    2021-02-06 04:01

    Well the best tool to trace function execution order is definitely viztracer. I would have to say that visualization is a huge factor when it comes to understanding a larger project.

    An interactive image like this makes it much easier to understand what's going on in your program, compared to cold terminal ascii.

    Also, it's a non-intrusive tool, which means you don't need to write a single line of code. Just install it and run your program with it.

    pip install viztracer
    viztracer your_script.py
    

    Another important factor here is that viztracer supports multi-thread and multi-process, and can visualize them in separate signals, on the same timeline, which you'll never achieve with terminal display.

提交回复
热议问题