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


Python reactor.running方法代码示例

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


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

示例1: execute

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def execute():
    cfg = Configuration(".bitmaskctl")
    print_json = '--json' in sys.argv

    cli = BitmaskCLI(cfg)
    cli.data = ['core', 'version']
    args = None if '--noverbose' in sys.argv else ['--verbose']

    if should_start(sys.argv):
        timeout_fun = cli.start
    else:
        def status_timeout(args):
            raise RuntimeError('bitmaskd is not running')
        timeout_fun = status_timeout

    try:
        yield cli._send(
            timeout=0.1, printer=_null_printer,
            errb=lambda: timeout_fun(args))
    except Exception, e:
        print(Fore.RED + "ERROR: " + Fore.RESET +
              "%s" % str(e))
        yield reactor.stop() 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:25,代码来源:bitmask_cli.py

示例2: signal_handler

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def signal_handler(signal, frame):
    global _user_abort

    state_machine_execution_engine = core_singletons.state_machine_execution_engine
    core_singletons.shut_down_signal = signal

    logger.info("Shutting down ...")

    try:
        if not state_machine_execution_engine.finished_or_stopped():
            state_machine_execution_engine.stop()
            state_machine_execution_engine.join(3)  # Wait max 3 sec for the execution to stop
    except Exception:
        logger.exception("Could not stop state machine")

    _user_abort = True

    # shutdown twisted correctly
    if reactor_required():
        from twisted.internet import reactor
        if reactor.running:
            plugins.run_hook("pre_destruction")
            reactor.callFromThread(reactor.stop)

    logging.shutdown() 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:27,代码来源:start.py

示例3: test_check_daemons

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def test_check_daemons(self):
        """
        The daemons are checked to be running every so often. When N=5 of these
        checks fail, the daemon will be restarted.
        """
        clock = Clock()
        dog = WatchDog(clock,
                       broker=AsynchronousPingDaemon("test-broker"),
                       monitor=AsynchronousPingDaemon("test-monitor"),
                       manager=AsynchronousPingDaemon("test-manager"))
        dog.start_monitoring()

        for i in range(4):
            clock.advance(5)
            dog.broker.fire_running(False)
            dog.monitor.fire_running(True)
            dog.manager.fire_running(True)
            self.assertEqual(dog.broker.boots, [])

        clock.advance(5)
        dog.broker.fire_running(False)
        dog.monitor.fire_running(True)
        dog.manager.fire_running(True)
        self.assertEqual(dog.broker.boots, [STOP, START]) 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:26,代码来源:test_watchdog.py

示例4: test_dont_write_pid_file_until_we_really_start

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def test_dont_write_pid_file_until_we_really_start(
            self, mock_watchdog, mock_daemonize, mock_reactor):
        """
        If the client can't be started because another client is still running,
        the client shouldn't be daemonized and the pid file shouldn't be
        written.
        """
        mock_watchdog().check_running.return_value = succeed([StubDaemon()])
        mock_reactor.crash.return_value = None
        self.log_helper.ignore_errors(
            "ERROR: The following daemons are already running: program-name")
        pid_file = self.makeFile()

        self.configuration.daemon = True
        self.configuration.pid_file = pid_file
        service = WatchDogService(self.configuration)

        service.startService()
        self.assertFalse(os.path.exists(pid_file))
        mock_daemonize.assert_not_called()
        mock_watchdog().check_running.assert_called_once_with()
        mock_watchdog().start.assert_not_called()
        mock_reactor.crash.assert_called_once_with() 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:25,代码来源:test_watchdog.py

示例5: start_wallet_monitoring

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def start_wallet_monitoring(self, syncresult):
        """ Once the initialization of the service
        (currently, means: wallet sync) is complete,
        we start the main monitoring jobs of the
        wallet service (currently, means: monitoring
        all new transactions on the blockchain that
        are recognised as belonging to the Bitcoin
        Core wallet with the JM wallet's label).
        """
        if not syncresult:
            jlog.error("Failed to sync the bitcoin wallet. Shutting down.")
            self.stopService()
            if reactor.running:
                reactor.stop()
            return
        jlog.info("Starting transaction monitor in walletservice")
        self.monitor_loop = task.LoopingCall(
            self.transaction_monitor)
        self.monitor_loop.start(5.0) 
开发者ID:JoinMarket-Org,项目名称:joinmarket-clientserver,代码行数:21,代码来源:wallet_service.py

示例6: toggleButtons

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def toggleButtons(self):
        """Refreshes accessibility of buttons in the (single, multiple) join
        tabs based on the current state as defined by the SpendStateMgr instance.
        Thus, should always be called on any update to that instance.
        """
        #The first two buttons are for the single join tab; the remaining 4
        #are for the multijoin tab.
        btns = (self.startButton, self.abortButton,
                self.schedule_set_button, self.schedule_generate_button,
                self.sch_startButton, self.sch_abortButton)
        if self.spendstate.runstate == 'ready':
            btnsettings = (True, False, True, True, True, False)
        elif self.spendstate.runstate == 'running':
            if self.spendstate.typestate == 'single':
                #can only abort current run, nothing else
                btnsettings = (False, True, False, False, False, False)
            elif self.spendstate.typestate == 'multiple':
                btnsettings = (False, False, False, False, False, True)
            else:
                assert False
        else:
            assert False

        for b, s in zip(btns, btnsettings):
            b.setEnabled(s) 
开发者ID:JoinMarket-Org,项目名称:joinmarket-clientserver,代码行数:27,代码来源:joinmarket-qt.py

示例7: execute_from_command_line

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def execute_from_command_line():
    # Limit concurrency in all thread-pools to ONE.
    from maasserver.utils import threads

    threads.install_default_pool(maxthreads=1)
    threads.install_database_unpool(maxthreads=1)
    # Disable all database connections in the reactor.
    from maasserver.utils import orm
    from twisted.internet import reactor

    assert not reactor.running, "The reactor has been started too early."
    reactor.callFromThread(orm.disable_all_database_connections)
    # Configure logging; Django is no longer responsible for this. Behave as
    # if we're always at an interactive terminal (i.e. do not wrap stdout or
    # stderr with log machinery).
    from provisioningserver import logger

    logger.configure(mode=logger.LoggingMode.COMMAND)
    # Hand over to Django.
    from django.core import management

    management.execute_from_command_line() 
开发者ID:maas,项目名称:maas,代码行数:24,代码来源:__init__.py

示例8: calc_iteration

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def calc_iteration(self):
        if not self.running or not reactor.running:
            debug(1, '%s exiting', self)
            return False
        if not self.last_t:
            self.last_t = time()
        now = time()
        if now - self.last_t >= self.period:
            self.rate = self.alpha*self.rate + \
                (1.0-self.alpha)*self.last_data/(now - self.last_t)
            self.last_data = 0
            self.last_t = now
            self.rate_vec.add(self.rate)
            #self.rate_filt = self.harmonic_mean(self.rate_vec.getBuffer())
            self.emit('update')
        reactor.callLater(self.period, self.calc_iteration)
        #return True 
开发者ID:ldecicco,项目名称:tapas,代码行数:19,代码来源:util.py

示例9: connectionLost

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def connectionLost(self, reason=None):
        """
        Called by Twisted when the connection is gone. Regardless of whether
        it was clean or not, we want to stop the reactor.
        """
        if self.fileobj is not None:
            self.fileobj.close()

        if reactor.running:
            reactor.stop() 
开发者ID:python-hyper,项目名称:hyper-h2,代码行数:12,代码来源:post_request.py

示例10: processEnded

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def processEnded(self, reason):
        log.info("Checker process ended with reason: {reason}", reason=reason)
        if reactor.running:
            reactor.stop() 
开发者ID:moira-alert,项目名称:worker,代码行数:6,代码来源:server.py

示例11: onExitSignal

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def onExitSignal(*a):
    print 'Closing Timeline?'
    if not reactor.running:
        os._exit(1)

    reactor.callFromThread(reactor.stop) 
开发者ID:Times-0,项目名称:Timeline,代码行数:8,代码来源:Start.py

示例12: start

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def start(self, raw_args):
        # XXX careful! Should see if the process in PID is running,
        # avoid launching again.
        import commands
        cmd = 'bitmaskd'
        if raw_args and ('--verbose' in raw_args or '-v' in raw_args):
            cmd += ' --verbose'
        commands.getoutput(cmd)
        self.cfg.set('bonafide', 'active', "")
        return defer.succeed(None) 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:12,代码来源:bitmask_cli.py

示例13: main

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def main():

    def signal_handler(signal, frame):
        if reactor.running:
            reactor.stop()
        sys.exit(0)

    reactor.callWhenRunning(reactor.callLater, 0, execute)
    signal.signal(signal.SIGINT, signal_handler)
    reactor.run() 
开发者ID:leapcode,项目名称:bitmask-dev,代码行数:12,代码来源:bitmask_cli.py

示例14: clientConnectionFailed

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def clientConnectionFailed(self, connector, reason):
        self.rx._callback('error', 'connection %s failed, reason=%s' % (connector, reason))
        if reactor.running:
            try: 
                reactor.stop()
            except error.ReactorNotRunning:
		pass 
开发者ID:rstms,项目名称:txTrader,代码行数:9,代码来源:monitor.py

示例15: clientConnectionLost

# 需要导入模块: from twisted.internet import reactor [as 别名]
# 或者: from twisted.internet.reactor import running [as 别名]
def clientConnectionLost(self, connector, reason):
        self.rx._callback('error', 'connection %s lost, reason=%s' % (connector, reason))
        if reactor.running:
            try:
                reactor.stop()
            except error.ReactorNotRunning:
		pass 
开发者ID:rstms,项目名称:txTrader,代码行数:9,代码来源:monitor.py


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