Django CPU intensive development server - how to analyze?

I notice that my django development server (version 1.1.1) on my local Windows7 computer uses a lot of CPU (~ 30%, according to the task manager python.exe entry) even in idle state, i.e. no request comes / goes. Is there an established way to analyze what might be causing this?

Thanks!

Martin

+6
python django cpu
source share
4 answers

FWIW, you have to do the profiling, but when you do, I bet you will find that the answer is "polling the changes in your files so that it can automatically reload." You can run a quick test using "python manage.py runningerver --noreload" and see how this affects CPU usage.

+12
source share

Hit-control-C and process failure. Most likely, it will work somewhere that he spends a lot of time.

Or you can use a profiler.

+3
source share
+2
source share

The standard approach is to use a profiler. If for some reason you cannot (for example, there is no profiler available in modpython Apache that runs your Django), your best option might just be your logging tool. View messages from your program and see what you can learn from them.

If you see the message β€œInput CalculateFoo ()” and then five seconds later β€œExiting CalculateFoo ()”, this is the main key. Or, if one particular function continues to print over and over.

Here's a short discussion of the Python log.

Python Debugging Tips

EDIT: I just noticed that you specifically said that this is on the Windows 7 desktop. So, use a profiler. But I will leave this answer to cover the general case.

0
source share

All Articles