def hijack_reactor():
        """Modifies Twisted's reactor with a dummy so user code does
        not block IPython.  This function returns the original
        'twisted.internet.reactor' that has been hijacked.

        NOTE: Make sure you call this *AFTER* you've installed
        the reactor of your choice.
        """
        from twisted import internet
        orig_reactor = internet.reactor

        class DummyReactor(object):
            def run(self):
                pass
            def __getattr__(self, name):
                return getattr(orig_reactor, name)
            def __setattr__(self, name, value):
                return setattr(orig_reactor, name, value)
        
        internet.reactor = DummyReactor()
        return orig_reactor
Modifies Twisted's reactor with a dummy so user code does
        not block IPython.  This function returns the original
        'twisted.internet.reactor' that has been hijacked.

        NOTE: Make sure you call this *AFTER* you've installed
        the reactor of your choice.
        
recipes/Python/410670_Integrating_Twisted_reactor/recipe-410670.py