Thanks. I'm having trouble integrating this or Andrew's idea into my example. The simplest case doesn't quite work right for me (I see '>>>' prompts, and can interact with the python interpreter but the banner appears at the end of the REPL after I press Ctrl+D, and then I never see the '>' prompts from my original program anymore)...was this what you had in mind? See the diff below.
@@ -6,6 +6,7 @@
without blocking the reactor.
"""
+import sys
from twisted.internet import stdio
from twisted.protocols import basic
@@ -22,7 +23,8 @@
code.interact()
def main():
- stdio.StandardIO(Echo())
+ stdio_obj = stdio.StandardIO(Echo())
+ sys.stderr = stdio_obj
from twisted.internet import reactor
reactor.run()