Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling Python Scripts running on Mod_wsgi

How can I profile a python script running on mod_wsgi on apache

I would like to use cProfile but it seems it requires me to invoke a function manually. Is there a way to enable cProfile globally and have it keep on logging results.

like image 619
The Unknown Avatar asked Jul 23 '09 05:07

The Unknown


1 Answers

You need to wrap you wsgi application function inside another function that just calls your function using cProfile and use that as the application. Or you can reuse existing WSGI middleware to do that for you, for example repoze.profile does pretty much what you seem to want.

like image 73
Ants Aasma Avatar answered Nov 18 '22 12:11

Ants Aasma