The Python standard library never ceases to surprise me. I knew about Twisted’s manhole but yesterday I ran across the code module, which is in the Python standard library.
The code module allows you to create a fully fledged Python REPL. So, in order to try it out I decided to implement a “backdoor” server for Tornado applications.
The idea is pretty simple, use Tornado’s TCPServer
to serve a Python interpreter. Of course you should only do this in localhost! The can come really useful for debugging, as it doesn’t take any resources from the application, and allows for live inspection.
The result is here on GitHub.
Here is an example, hope you like it!
[gist]https://gist.github.com/3739834[/gist]
:wq