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

Jean-Paul Calderone exarkun at divmod.com
Wed Nov 5 08:05:21 EST 2008

On Wed, 5 Nov 2008 17:41:44 +1100, Andrew Bennetts <andrew-twisted at puzzling.org> wrote:
>Jean-Paul Calderone wrote:
>> On Wed, 5 Nov 2008 15:11:08 +1100, Andrew Bennetts <andrew-twisted at puzzling.org> wrote:
>>> 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).
>> 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.
>It matters just because it makes it clear that yes, “from twisted.internet
>import reactor” really does Just Work, all the time.

Sure.  But even if it didn't, you'd be alright.

Plus, parameterized reactor makes unit testing easier.


More information about the Twisted-web mailing list