Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No output from pycharm profiling when running a Flask container

Tags:

python

pycharm

Running PyCharm 4.5.3 Build #141.1899 Professional Edition and licensed. I run a Flask app using the profiler command using a configuration similar to:

python app.py

which looks like:

def create_app():
app = Flask(__name__, static_folder='static')
app.register_blueprint(
    consumer_v1.bp,
    url_prefix='/consumer/v1')
return app

app = create_app()

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=5001)

When I goto "Run -> Profile App" I see the following on the console:

   /Users/james/.virtualenvs/trustmile-api/bin/python   /Applications/PyCharm.app/Contents/helpers/profiler/run_profiler.py 127.0.0.1 49537 /Users/james/Documents/workspace/trustmile-backend/trustmile/api_stubs/api_stubs/__init__.py
Starting cProfile profiler

2015-09-01 07:00:25,717 INFO  [werkzeug][MainThread]  * Running on http://0.0.0.0:5001/ (Press CTRL+C to quit)
2015-09-01 07:00:25,723 INFO  [werkzeug][MainThread]  * Restarting with stat
2015-09-01 07:00:32,801 INFO  [werkzeug][Thread-1] 127.0.0.1 - - [01/Sep/2015 07:00:32] "POST /consumer/v1/account/password HTTP/1.1" 403 -
Snapshot saved to /Users/XXXX/Library/Caches/PyCharm40/snapshots/trustmile-backend5.pstat
Process finished with exit code 0

However nothing is shown in the UI as shown below.

enter image description here

Any help greatly appreciated.

like image 267
silverdagger Avatar asked Aug 31 '15 21:08

silverdagger


People also ask

How do I profile a Python script in PyCharm?

Start the profiling sessionon the main toolbar and select Profile <current run. debug configuration name> or select the same command from Run in the main menu. Ensure that the profiler has started in the dedicated tab of the Run tool window. Saves the profiling results in the <project name>.

How do I debug a Flask app in PyCharm?

The default value is 'development'. Select this checkbox to enable the built-in Flask debug mode. With this mode, the development server will be automatically reloaded on any code change enabling continuous debugging.


1 Answers

To fix this I simply installed yappi instead of the default python profiler.

pip install yappi

I hope this works for you too!

like image 98
silverdagger Avatar answered Oct 16 '22 21:10

silverdagger