How to debug python application under uWSGI?

后端 未结 3 2104
遥遥无期
遥遥无期 2020-12-24 00:50

When I\'m trying to use python pdb debugger under uWSGI, the execution doesn\'t stop on breakpoint, it just return trackback.

here is the code:

def a         


        
相关标签:
3条回答
  • 2020-12-24 01:31

    Being a server, uWSGI closes the stdin (effectively it remaps it to /dev/null).

    If you need stdin (as when you need a terminal debugger) add:

    --honour-stdin
    
    0 讨论(0)
  • 2020-12-24 01:33

    try this

    uwsgi --http 127.0.0.1:7777  --wsgi-file uwsgi_test.py --logto /path/to/log/log.txt
    
    0 讨论(0)
  • 2020-12-24 01:53

    Install remote debugger.

    pip install remote-pdb
    

    Set breakpoint somewhere in application.

    from remote_pdb import RemotePdb
    RemotePdb('127.0.0.1', 4444).set_trace()
    

    Connect to remote debugger via telnet

    # Restart uwsgi to pick up changes
    ...
    
    # Trigger the breakpoint, (any action to evaluate the set_trace call)
    ...
    
    # Connect to debugger
    telnet 127.0.0.1 4444
    

    You will likely want to run uWSGI with a single worker/thread, so that the remote debuggers do not step on one another.

    0 讨论(0)
提交回复
热议问题