[Twisted-Python] Using Twisted together with Windows Namespace Extensions

Andrew Bennetts andrew-twisted at puzzling.org
Tue Mar 2 05:30:00 MST 2004


On Tue, Mar 02, 2004 at 10:49:24AM +0100, Thorsten Henninger wrote:
[...]
> Well, I do not really understand, how they differ.
> For example:
> reactor.runFromThread
> reactor.runInThread
> 
> and what is the difference between
> threads.deferToThread and reactor.callInThread ?
> Both methods worked fine.

Have you seen these links?

     http://twistedmatrix.com/documents/current/howto/threading
     http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorThreads.html#callFromThread
     http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorThreads.html#callInThread
     http://twistedmatrix.com/documents/current/api/twisted.internet.threads.html#deferToThread

Note that deferToThread is just a simple (but useful!) wrapper around
callInThread -- you can read the implementation in
twisted/internet/threads.py, it's quite short.

Let us know if it still doesn't make sense.  Those docstrings are a little
confusing.

> Is it threadsafe to run the reactor in a thread?

The reactor doesn't care which thread it is run in (although if it's not
Python's main thread you might want to set installSignalHandlers=0).

-Andrew.





More information about the Twisted-Python mailing list