[Twisted-web] Having reactor run at the main thread make things harder for late adopters

Andrew Bennetts andrew-twisted at puzzling.org
Tue Nov 4 23:11:08 EST 2008


Tzury Bar Yochay wrote:
> >
> >> At this stage the main problem I see is having transport.write will
> >> have data transmitted immediately when called from another thread.
> >
> > When calling into Twisted from non-Twisted threads, use reactor.callFromThread.
> > See <http://twistedmatrix.com/projects/core/documentation/howto/threading.html>.
> 
> I actually saw this reactor.callFromThread but weren't sure whether it
> is a singelton i.e. I can use it in another module by simply importing
> reactor and calling it and it will affect the same I called .run on in
> another module. I checked it right now and it works.

Yes, it is a singleton.  As
<http://twistedmatrix.com/projects/core/documentation/howto/reactor-basics.html>
says:

    You can get to the reactor object using the following code:

        from twisted.internet import reactor

The documentation could perhaps be clearer about this (that document implies,
but doesn't directly state, that there's only one reactor instance).

-Andrew.




More information about the Twisted-web mailing list