rkern / line_profiler

(OLD REPO) Line-by-line profiling for Python - Current repo ->
https://github.com/pyutils/line_profiler
Other
3.6k stars 254 forks source link

Error when starting gunicorn with kernprof #40

Closed pallix closed 7 years ago

pallix commented 8 years ago

An error occurs when starting a gunicorn server with kernprof:

kernprof  -l ./bin/gunicorn --paste etc/development.ini --forwarded-allow-ips="127.0.0.1" -t 6000

Error: gunicorn
Wrote profile results to gunicorn.lprof

gunicorn.lprof is then empty:

cat gunicorn.lprof 
��F�_line_profiler�� LineStats���)}���}�(�unit�G>�����퍌timings�}�ub.⏎ 

I'm using Python 3.4.3

rkern commented 8 years ago

gunicorn runs your code in a subprocess which isn't under the control of kernprof, so it will never work. From a quick perusal of its documentation, I don't see a flag to tell it to run all in the same process for development purposes (which is fine; that's not its job). You can probably use a simple script that uses wsgiref.simple_server.make_server() to kick off your app instead when you need to do this profiling.