Django / WSGI - How to profile partial request? My profiling tools are per-request but app runs out of memory before then

∥☆過路亽.° 提交于 2019-12-11 14:19:20

问题


How can I profile my python / django application which is crashing on a single request after 100 seconds of hogging more memory?

All I see in top is that the wsgi process is consuming memory slowly until it crashes.

The only profiling techniques I know run on a full request/response cycle but I'm not able to finish a request. What then?

I might even run the dev server and try to kill it mid-request and see where the stack is.


回答1:


A bit fiddly and will have some overhead, but you could use sys.setprofile() to provide a function to be called on entry and exit from functions and dump progress of calls out to a log file yourself, potentially with check of memory in use at the same time.

http://docs.python.org/dev/library/sys.html#sys.setprofile

Also perhaps check out heapy as a way of getting console type access into your live process to dump out memory/object usage.



来源:https://stackoverflow.com/questions/11348611/django-wsgi-how-to-profile-partial-request-my-profiling-tools-are-per-reque

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!