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

前端 未结 4 876
清酒与你
清酒与你 2021-01-31 09:34

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 qu

4条回答
  •  萌比男神i
    2021-01-31 10:05

    Settings > Project Settings > Python Debugger

    There's an option in there to enable "gevent compatible debugging".

    Then, go into your debugger settings (shortcut is through the toolbar, click the dropdown near the play/debug icons and select "Edit Configurations"

    Set the "Script" to your virtualenv's isntallation of gunicorn, something like:

    /Users/iandouglas/.virtualenvs/defaultenv/bin/gunicorn

    Set the "Script Parameters" to something like -b 192.168.1.1:9000 app:yourappname (assuming your primary starting script is called app.py and you're refering to it as 'yourappname'

    the "Working directory" will be automatically set otherwise set it to wherever your code lives: /Users/iandouglas/PycharmProjects/MyExampleApp

    I have a separate config file for my gunicorn settings, which specifies a host/port but I still had to specify the -b 0.0.0.0:5001 parameter to force gunicorn to bind to all IPs on my machine on port 5001.

    p.s.

    One important step is to add this envvar as pointed out here

    PYDEVD_USE_CYTHON=NO
    

提交回复
热议问题