News for hackers. Stuff that matters.
Re:Say “no” to import side‐effects in Python by taejo on Saturday April 05, 2014 @05:02AM (#7536459)
Agreed. Twisted's behaviour of installing a reactor on import has caused me problems which could be worked around by importing conditionally or at a later time, but in cases like this, where one is importing modules dynamically, one doesn't know ahead of time which workarounds one needs.
Re:Say “no” to import side‐effects in Python by jzwinck on Saturday April 05, 2014 @05:22AM (#7536500)
Twisted's problem is the good old singleton (anti-)pattern. There can only be one reactor ever, and most galling of all, it can never be restarted once stopped.
Re:Say “no” to import side‐effects in Python by thristian on Saturday April 05, 2014 @07:38AM (#7536726)
It should be said that Twisted has put a lot of effort into making it possible to making it possible to deal with multiple reactors (mostly so they can run their test suite including all their supported reactors), and even to make it possible to unit-test Twisted code without a reactor at all (by having standardized mocks for the various things the reactor does).

Of course, that doesn't help the mountains of code written for Twisted that expect a singleton reactor, so we're stuck with it for the foreseeable future. Perhaps in the Brave New World of Python 3, where Twisted is just an implementation detail of the asyncio module, life will be better.

Re:Say “no” to import side‐effects in Python by jzwinck on Saturday April 05, 2014 @08:36AM (#7536852)
Why can't we at least restart a stopped reactor? That seems possible without breaking compatibility.