[Twisted-Python] Newbie Question: Running Twisted in a thread?

brett hartshorn bhartsho at yahoo.com
Tue Jun 22 16:41:36 EDT 2004


So Twisted can not be run inside a thread, and must be 'on top' and start my other threads?  
After reading: http://twistedmatrix.com/documents/current/howto/threading
it looks like i will have to schedule my own threads to be run inside the twisted main event loop.

What is the best way to make my threads thread safe?  Will the code below work?

from twisted.internet import reactor

def myThread(value):
   print value

reactor.callInThread(myThread, 1)

so when reactor enters its mainloop via reactor.run() it will call once per loop myThread, is this
correct?  Will the call to myThread block all other threads, and it should be thread safe then,

Is there a way to have myThread called at a certian time interval?  I'd like to update it at 30hz.
 My old code just looked like this:

def myThread(value):
   while 1:

thanks for the help,

Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.

More information about the Twisted-Python mailing list