How to debug flask.app with pycharm 2.x that's running on gunicorn

Viewed 17415

I'm developing a flask.app that uses web socket functionality and installed flask-socket to provide that. So the flask-socket developer recommends gunicorn as web server. My question is now how to connect the remove debugger of pycharm with gunicorn to intercept the execution with breakpoints.

4 Answers

My case for PyCharm 2018.1.3 Professional:

  1. Go to run/debug configurations creating-and-editing-run-debug-configurations

  2. Choose new "Python" config

  3. Script path: your_path_to_/venv/bin/gunicorn
  4. Parameters(for my case): -b :5001 --access-logfile - --error-logfile - "run:create_application()"
  5. Python interpreter: your venv python version for project
  6. Working directory: path to your project
  7. Save and press DEBUG (Shift+F9)
  8. be happy!

I was trying to debug on Pycharm 2020.2.1 and the break points weren't correctly working even though the Gevent compatible debugging was enabled. It turned out that I had to disable Cython for my run configuration via setting the environment variable as described here to make it work.

PYDEVD_USE_CYTHON=NO
Related