It's very easy to implement this using SocketServer which is in the standard library, this way even if you're not running under Twised, you can still have this feature. I've created ingress just for this (easy_install ingress), using it is super easy:
import ingress ingress.install()
The code itself is not that complicated. (Could have been simpler if there was a way to override writing to stdout in code.InteractiveConsole).