Django Gunicorn Debug

后端 未结 5 447
陌清茗
陌清茗 2021-01-11 23:52

Initially I had a Django app with the included testing server. To debug this setup, I can just add a import pdb; pdb.set_trace() anywhere in the code and have a

5条回答
  •  庸人自扰
    2021-01-12 00:35

    Ok I've recently stumbed upon similar problem. I wasn't able to apply @dudklein solution (I get I/O Errors while debugger was trying to take input - ipdb, pdb etc.)

    I used remote python debbuger - winpdb and it's embedded debugging.

    1. install winpdb in Your virtualenv

      pip install winpdb
      
    2. import and run embedded debugger in Your code:

      import rpdb2
      rpdb2.start_embedded_debugger('pass')
      
    3. run gunicorn with --timeout argument

      gunicorn -t 3600 env:application
      
    4. run proper view using browser eg. http://127.0.0.1:8000/your-view/

    5. connect to embedded debugger using winpdb:

      winpdb -a /path/to/django/app/views.py
      

      It will prompt You for a password (use one You set in Your code, in my example it is 'pass') and run nice GUI with debugger.

    6. if You need tutorial for winpdb - here You are.

    enter image description here

提交回复
热议问题