[Twisted-Python] Global reactor unit tests in the Twisted test suite

Jonathan Lange jml at mumak.net
Tue Nov 8 06:33:33 EST 2011

On Tue, Nov 8, 2011 at 5:44 AM, Glyph Lefkowitz <glyph at twistedmatrix.com> wrote:
>> On Nov 7, 2011, at 10:25 AM, exarkun at twistedmatrix.com wrote:
>>> reactor = getUtility(IReactor)?
>> That's not really a solution.  It's the barest glimpse of a large system
>> which might be applied as a solution.  Do you want to expand it?
> I'd like to echo this request for exposition.  My understanding is that
> 'getUtility' is just a baroque way to access a global variable, with most of
> the disadvantages of said globalness intact.  What does it provide that our
> existing import strategy doesn't?

An extra layer of abstraction and XML-based configuration – what's not to love?

It could allow for a clearer expression of dependency. Something that
only uses IReactorTime would only get the utility for that. This would
in turn make it easier to swap out only parts for testing, or to do
things like "speed up or slow down time from a protocol's

However, you're right. Ultimately, it's a process-wide configuration
setting. That means that setting it is a slightly politer form of
monkey patching and that it's not fine-grained enough to do the other
things you suggested (e.g. "suspending a group of related objects").


More information about the Twisted-Python mailing list