當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。