How to debug python application under uWSGI?

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

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.