[Twisted-Python] Running a reactor in IPython

Thorsten Henninger henni at brainbot.com
Tue Mar 2 05:56:37 EST 2004


Hi all,

At my company, we heavily use IPython for debugging and testing.
The following code shows, how to run a reactor together with IPython:

from twisted.internet import reactor
from twisted.python import threadable
threadable.init(1)

import threading
class MyThread(threading.Thread):
     def run(self):
          print "starting reactor.."
          reactor.run(installSignalHandlers=False)
         
if __name__=="__main__":
     m=MyThread()
     m.start()
     from IPython.Shell import IPythonShellEmbed
     ipshell = IPythonShellEmbed()
     ipshell() # this call anywhere in your program will start IPython


have fun,

Thorsten

-- 
brainbot technologies AG 
boppstrasse . 64 . 55118 mainz . germany
fon +49 6131 211639-1 . fax +49 6131 211639-2
http://brainbot.com/  mailto:henni at brainbot.com





More information about the Twisted-Python mailing list