Python twisted.internet.error.ReactorAlreadyInstalledError() Examples

The following are 10 code examples of twisted.internet.error.ReactorAlreadyInstalledError(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module twisted.internet.error , or try the search function .
Example #1
Source File: main.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def installReactor(reactor):
    """
    Install reactor C{reactor}.

    @param reactor: An object that provides one or more IReactor* interfaces.
    """
    # this stuff should be common to all reactors.
    import twisted.internet
    import sys
    if 'twisted.internet.reactor' in sys.modules:
        raise error.ReactorAlreadyInstalledError("reactor already installed")
    twisted.internet.reactor = reactor
    sys.modules['twisted.internet.reactor'] = reactor 
Example #2
Source File: test_main.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def test_alreadyInstalled(self):
        """
        If a reactor is already installed, L{installReactor} raises
        L{ReactorAlreadyInstalledError}.
        """
        with NoReactor():
            installReactor(object())
            self.assertRaises(ReactorAlreadyInstalledError, installReactor,
                              object()) 
Example #3
Source File: test_main.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def test_errorIsAnAssertionError(self):
        """
        For backwards compatibility, L{ReactorAlreadyInstalledError} is an
        L{AssertionError}.
        """
        self.assertTrue(issubclass(ReactorAlreadyInstalledError,
                        AssertionError)) 
Example #4
Source File: start.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def install_reactor():
    from twisted.internet import gtk3reactor
    from twisted.internet.error import ReactorAlreadyInstalledError
    try:
        # needed for GLib.idle_add, and signals
        gtk3reactor.install()
    except ReactorAlreadyInstalledError:
        pass 
Example #5
Source File: main.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def installReactor(reactor):
    """
    Install reactor C{reactor}.

    @param reactor: An object that provides one or more IReactor* interfaces.
    """
    # this stuff should be common to all reactors.
    import twisted.internet
    import sys
    if 'twisted.internet.reactor' in sys.modules:
        raise error.ReactorAlreadyInstalledError("reactor already installed")
    twisted.internet.reactor = reactor
    sys.modules['twisted.internet.reactor'] = reactor 
Example #6
Source File: test_main.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def test_alreadyInstalled(self):
        """
        If a reactor is already installed, L{installReactor} raises
        L{ReactorAlreadyInstalledError}.
        """
        with NoReactor():
            installReactor(object())
            self.assertRaises(ReactorAlreadyInstalledError, installReactor,
                              object()) 
Example #7
Source File: test_main.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def test_errorIsAnAssertionError(self):
        """
        For backwards compatibility, L{ReactorAlreadyInstalledError} is an
        L{AssertionError}.
        """
        self.assertTrue(issubclass(ReactorAlreadyInstalledError,
                        AssertionError)) 
Example #8
Source File: test_main.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def test_alreadyInstalled(self):
        """
        If a reactor is already installed, L{installReactor} raises
        L{ReactorAlreadyInstalledError}.
        """
        # Because this test runs in trial, assume a reactor is already
        # installed.
        self.assertRaises(ReactorAlreadyInstalledError, installReactor,
                          object()) 
Example #9
Source File: test_main.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def test_errorIsAnAssertionError(self):
        """
        For backwards compatibility, L{ReactorAlreadyInstalledError} is an
        L{AssertionError}.
        """
        self.assertTrue(issubclass(ReactorAlreadyInstalledError,
                        AssertionError)) 
Example #10
Source File: scripts.py    From maas with GNU Affero General Public License v3.0 5 votes vote down vote up
def init_asyncio_reactor():
    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
    try:
        asyncioreactor.install()
    except error.ReactorAlreadyInstalledError:
        pass