[Twisted-web] Having reactor run at the main thread make things
harder for late adopters
exarkun at divmod.com
Wed Nov 5 00:33:39 EST 2008
On Wed, 5 Nov 2008 15:11:08 +1100, Andrew Bennetts <andrew-twisted at puzzling.org> wrote:
>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
> 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).
Although I don't see how it matters if it's a singleton or not. :) If it
weren't, you could just pass the reactor you were using to the thread that
needed to use it.
More information about the Twisted-web