Profil flask app
Hello, is there anyway that I can profile a flask app with profiling?
There's nothing special to profile a Flask app if you can run the Web server by a Python file.
# run_server.py
from hello import app
if __name__ == '__main__':
app.run(port=5000)
$ profiling live run_server.py
If you use flask run command, try -m option and -- delimiter:
$ FLASK_APP=hello.py profiling live -m flask run -- -h 0.0.0.0 -p 5555
I was able to run the profiler but the output only shows click and werkzeug steps. Cant really see which endpoint/which model method calls are being the bottleneck.
command I used;
profiling --dump=profiler/blah.prf -S -m flask run -- -h 0.0.0.0 -p 5000 --no-reload
@sinanm89 Would you try flask run with --without-threads?
Hah! That worked. I actually have the post methods now. Thanks so much for your hard work and suggestions @sublee , I'd say you can close this issue.
reiterating the working command to profile a flask app for anyone else stumbling around;
$ profiling --dump=blah.prf -S -m flask run -- -h 0.0.0.0 -p 5000 --no-reload --without-threads
I'm running my app through uwsgi in a docker container, where do I run profiling?