[Twisted-Python] Running twisted app in a different thread

Reza Lotun rlotun at gmail.com
Tue Jan 5 11:46:37 EST 2010


Hi Devraj,

> Is it possible to ask the Twisted application to run in a sea prate thread?

Yes it is possible. Simply start the reactor in a thread, but run it as:

reactor.run(installSignalHandlers=False)

If you do it this way you're going to have to handle signals yourself.

You're going to have to be very careful about calling code in the
Twisted thread from other threads as Twisted isn't threadsafe. To do
this properly take a look at reactor.callFromThread.

Cheers,
Reza


-- 
Reza Lotun
mobile: +44 (0)7521 310 763
email:  rlotun at gmail.com
work:   reza at tweetdeck.com
twitter: @rlotun



More information about the Twisted-Python mailing list