Skip to content
This repository has been archived by the owner on Aug 24, 2020. It is now read-only.

Profil flask app #45

Open
xlqian opened this issue Nov 30, 2017 · 5 comments
Open

Profil flask app #45

xlqian opened this issue Nov 30, 2017 · 5 comments

Comments

@xlqian
Copy link

xlqian commented Nov 30, 2017

Hello, is there anyway that I can profile a flask app with profiling?

@sublee
Copy link
Contributor

sublee commented Dec 2, 2017

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

@sinanm89
Copy link

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

@sublee
Copy link
Contributor

sublee commented Oct 11, 2019

@sinanm89 Would you try flask run with --without-threads?

@sinanm89
Copy link

sinanm89 commented Oct 15, 2019

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

@simkessy
Copy link

simkessy commented Apr 5, 2020

I'm running my app through uwsgi in a docker container, where do I run profiling?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants