当前位置: 首页>>代码示例>>Python>>正文


Python error.ReactorAlreadyRunning方法代码示例

本文整理汇总了Python中twisted.internet.error.ReactorAlreadyRunning方法的典型用法代码示例。如果您正苦于以下问题:Python error.ReactorAlreadyRunning方法的具体用法?Python error.ReactorAlreadyRunning怎么用?Python error.ReactorAlreadyRunning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.error的用法示例。


在下文中一共展示了error.ReactorAlreadyRunning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: startRunning

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def startRunning(self):
        """
        Method called when reactor starts: do some initialization and fire
        startup events.

        Don't call this directly, call reactor.run() instead: it should take
        care of calling this.

        This method is somewhat misnamed.  The reactor will not necessarily be
        in the running state by the time this method returns.  The only
        guarantee is that it will be on its way to the running state.
        """
        if self._started:
            raise error.ReactorAlreadyRunning()
        if self._startedBefore:
            raise error.ReactorNotRestartable()
        self._started = True
        self._stopped = False
        if self._registerAsIOThread:
            threadable.registerAsIOThread()
        self.fireSystemEvent('startup') 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:23,代码来源:base.py

示例2: test_cantRegisterAfterRun

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def test_cantRegisterAfterRun(self):
        """
        It is not possible to register a C{Application} after the reactor has
        already started.
        """
        reactor = gireactor.GIReactor(useGtk=False)
        self.addCleanup(self.unbuildReactor, reactor)
        app = Gio.Application(
            application_id='com.twistedmatrix.trial.gireactor',
            flags=Gio.ApplicationFlags.FLAGS_NONE)

        def tryRegister():
            exc = self.assertRaises(ReactorAlreadyRunning,
                                    reactor.registerGApplication, app)
            self.assertEqual(exc.args[0],
                             "Can't register application after reactor was started.")
            reactor.stop()
        reactor.callLater(0, tryRegister)
        ReactorBuilder.runReactor(self, reactor) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_gireactor.py

示例3: startRunning

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def startRunning(self):
        """
        Method called when reactor starts: do some initialization and fire
        startup events.

        Don't call this directly, call reactor.run() instead: it should take
        care of calling this.

        This method is somewhat misnamed.  The reactor will not necessarily be
        in the running state by the time this method returns.  The only
        guarantee is that it will be on its way to the running state.
        """
        if self._started:
            raise error.ReactorAlreadyRunning()
        self._started = True
        self._stopped = False
        threadable.registerAsIOThread()
        self.fireSystemEvent('startup') 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:20,代码来源:base.py

示例4: run

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def run(self):
        try:
            reactor.run(installSignalHandlers=False)
        except ReactorAlreadyRunning:
            # Ignore error about reactor already running
            pass 
开发者ID:sammchardy,项目名称:python-binance,代码行数:8,代码来源:websockets.py

示例5: registerGApplication

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def registerGApplication(self, app):
        """
        Register a C{Gio.Application} or C{Gtk.Application}, whose main loop
        will be used instead of the default one.

        We will C{hold} the application so it doesn't exit on its own. In
        versions of C{python-gi} 3.2 and later, we exit the event loop using
        the C{app.quit} method which overrides any holds. Older versions are
        not supported.
        """
        if self._gapplication is not None:
            raise RuntimeError(
                "Can't register more than one application instance.")
        if self._started:
            raise ReactorAlreadyRunning(
                "Can't register application after reactor was started.")
        if not hasattr(app, "quit"):
            raise RuntimeError("Application registration is not supported in"
                               " versions of PyGObject prior to 3.2.")
        self._gapplication = app
        def run():
            app.hold()
            app.run(None)
        self._run = run

        self._crash = app.quit 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:28,代码来源:gireactor.py

示例6: test_multipleRun

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def test_multipleRun(self):
        """
        C{reactor.run()} raises L{ReactorAlreadyRunning} when called when
        the reactor is already running.
        """
        events = []
        def reentrantRun():
            self.assertRaises(ReactorAlreadyRunning, reactor.run)
            events.append("tested")
        reactor = self.buildReactor()
        reactor.callWhenRunning(reentrantRun)
        reactor.callWhenRunning(reactor.stop)
        self.runReactor(reactor)
        self.assertEqual(events, ["tested"]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:16,代码来源:test_core.py

示例7: connect_to_socket

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def connect_to_socket(port, observers=None):
        if port is None:
            raise ValueError('port', port)
        
        api_server = token_ops.get_api_server()
        if api_server is not None:
            if api_server.startswith('https://'):
                api_server = api_server.replace('https://', 'wss://')
            if api_server.endswith('/'):
                api_server = api_server[:-1]
        
            url = api_server + ':' + str(port)
            
            logging.info('connect_to_socket')
            logging.info('Establishing socket connection:  %s' % url)
            
            factory = WebSocketClientFactory(url)
            factory.protocol = IQStreamer
            
            connectWS(factory)
            
            if observers is not None:
                publisher = StreamPublisher()
                for obs in observers:
                    publisher.register(obs)
            
            try:
                factory.reactor.run(installSignalHandlers=False)
            except error.ReactorAlreadyRunning:
                pass 
开发者ID:pcinat,项目名称:QuestradeAPI_PythonWrapper,代码行数:32,代码来源:IQStreamer.py

示例8: test_multipleRun

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def test_multipleRun(self):
        """
        C{reactor.run()} raises L{ReactorAlreadyRunning} when called when
        the reactor is already running.
        """
        events = []
        def reentrantRun():
            self.assertRaises(ReactorAlreadyRunning, reactor.run)
            events.append("tested")
        reactor = self.buildReactor()
        reactor.callWhenRunning(reentrantRun)
        reactor.callWhenRunning(reactor.stop)
        reactor.run()
        self.assertEqual(events, ["tested"]) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:16,代码来源:test_core.py

示例9: start_process

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def start_process(process, stop_after_job):
    try:
        process.start(stop_after_job)
    except ReactorAlreadyRunning:
        pass 
开发者ID:fhamborg,项目名称:news-please,代码行数:7,代码来源:single_crawler.py

示例10: start

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def start(self):
        site = server.Site(AdminPage(self))
        reactor.listenTCP(port, site)
        logger.log(logging.INFO,
                   "Now listening for connections on port %d...",
                   port)
        try:
            if not reactor.running:
                reactor.run(installSignalHandlers=0)
        except ReactorAlreadyRunning:
            pass 
开发者ID:barronwaffles,项目名称:dwc_network_server_emulator,代码行数:13,代码来源:admin_page_server.py

示例11: start

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def start(self):
        endpoint = serverFromString(
            reactor,
            "tcp:%d:interface=%s" % (address[1], address[0])
        )
        conn = endpoint.listen(PlayerFactory())

        try:
            if not reactor.running:
                reactor.run(installSignalHandlers=0)
        except ReactorAlreadyRunning:
            pass 
开发者ID:barronwaffles,项目名称:dwc_network_server_emulator,代码行数:14,代码来源:gamespy_profile_server.py

示例12: start

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def start(self):
        site = server.Site(RegPage(self))
        reactor.listenTCP(port, site)
        logger.log(logging.INFO,
                   "Now listening for connections on port %d...",
                   port)
        try:
            if not reactor.running:
                reactor.run(installSignalHandlers=0)
        except ReactorAlreadyRunning:
            pass 
开发者ID:barronwaffles,项目名称:dwc_network_server_emulator,代码行数:13,代码来源:register_page.py

示例13: start

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def start(self):
        endpoint_search = serverFromString(
            reactor,
            "tcp:%d:interface=%s" % (address[1], address[0])
        )
        conn_search = endpoint_search.listen(GamestatsFactory())

        try:
            if not reactor.running:
                reactor.run(installSignalHandlers=0)
        except ReactorAlreadyRunning:
            pass 
开发者ID:barronwaffles,项目名称:dwc_network_server_emulator,代码行数:14,代码来源:gamespy_gamestats_server.py

示例14: start

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def start(self):
        endpoint_search = serverFromString(
            reactor,
            "tcp:%d:interface=%s" % (address[1], address[0])
        )
        conn_search = endpoint_search.listen(PlayerSearchFactory())

        try:
            if not reactor.running:
                reactor.run(installSignalHandlers=0)
        except ReactorAlreadyRunning:
            pass 
开发者ID:barronwaffles,项目名称:dwc_network_server_emulator,代码行数:14,代码来源:gamespy_player_search_server.py

示例15: start

# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyRunning [as 别名]
def start(self):
        endpoint = serverFromString(
            reactor, "tcp:%d:interface=%s" % (address[1], address[0])
        )
        conn = endpoint.listen(SessionFactory(self.qr))

        try:
            if not reactor.running:
                reactor.run(installSignalHandlers=0)
        except ReactorAlreadyRunning:
            pass 
开发者ID:barronwaffles,项目名称:dwc_network_server_emulator,代码行数:13,代码来源:gamespy_server_browser_server.py


注:本文中的twisted.internet.error.ReactorAlreadyRunning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。