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


Python MultiService.stopService方法代码示例

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


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

示例1: stopService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
    def stopService(self):
        """
        Stop all child services, then stop the subprocess, if it's running.
        """

        if self.delayedShutdown:
            # We're still in the process of initializing the database, so
            # delay shutdown until the shutdownDeferred fires.
            d = self.shutdownDeferred = Deferred()
            d.addCallback(lambda ignored: MultiService.stopService(self))
        else:
            d = MultiService.stopService(self)

        def superStopped(result):
            # If pg_ctl's startup wasn't successful, don't bother to stop the
            # database.  (This also happens in command-line tools.)
            if self.shouldStopDatabase:
                monitor = PostgresMonitor()
                args = [
                    self._pgCtl, "stop",
                    "--log={}".format(self.logFile),
                ]
                log.info("Requesting postgres stop via: {args}", args=args)
                self.reactor.spawnProcess(
                    monitor, self._pgCtl,
                    args,
                    env=self.env, path=self.workingDir.path,
                    uid=self.uid, gid=self.gid,
                )
                return monitor.completionDeferred
        return d.addCallback(superStopped)
开发者ID:red-hood,项目名称:calendarserver,代码行数:33,代码来源:subpostgres.py

示例2: stopService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
    def stopService(self):
        """
        Stop all child services, then stop the subprocess, if it's running.
        """

        if self.delayedShutdown:
            # We're still in the process of initializing the database, so
            # delay shutdown until the shutdownDeferred fires.
            d = self.shutdownDeferred = Deferred()
            d.addCallback(lambda ignored: MultiService.stopService(self))
        else:
            d = MultiService.stopService(self)

        def superStopped(result):
            # If pg_ctl's startup wasn't successful, don't bother to stop the
            # database.  (This also happens in command-line tools.)
            if self.shouldStopDatabase:
                monitor = _PostgresMonitor()
                pgCtl = self.pgCtl()
                # FIXME: why is this 'logfile' and not self.logfile?
                self.reactor.spawnProcess(monitor, pgCtl,
                    [pgCtl, '-l', 'logfile', 'stop'],
                    env=self.env, path=self.workingDir.path,
                    uid=self.uid, gid=self.gid,
                )
                return monitor.completionDeferred
        return d.addCallback(superStopped)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:29,代码来源:subpostgres.py

示例3: ServerManagerFrameImpl

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
class ServerManagerFrameImpl(ServerManagerFrame):
   def __init__(self, *args, **kw):
      super(self.__class__, self).__init__(*args, **kw)
      
      #self.hostsDialog = HostsDialogImpl(self)
      
      #servers = dict([((gethostbyname(k[0]), k[1]), v) for k, v in servers.iteritems()])
      
      # TODO?: make this Service a serialized Application then load from XML
      self.services = MultiService()
      for klass, addresses in servers.iteritems():
         module, klass = klass.rsplit('.', 1)
         self.services.addService(__import__(module).__dict__[klass](addresses))
      
      # setup log window
      class Redirect(object):
         def write(inner, *args, **kw):
            self.text_ctrl_log.AppendText(args[0])
         def flush(self, *args, **kw): pass
      log.startLogging(Redirect())
         
   def isValidClick(self, button, other):
      if other.GetValue():
         button.SetValue(True)
         other.SetValue(False)
         return True
      else:
         button.SetValue(not button.GetValue())
         return False

   def StartServer(self, event):
      # NOTE: button is already flipped by the time we get here
      button = self.button_start
      other = self.button_stop
      if not self.isValidClick(button, other):
         return
      self.services.startService()

   def StopServer(self, event):
      # NOTE: button is already flipped by the time we get here
      button = self.button_stop
      other = self.button_start
      if not self.isValidClick(button, other):
         return
      self.services.stopService()
   
   def OnHostsButton(self, event):
      self.hostsDialog.Show(not self.hostsDialog.IsShown())
开发者ID:istobran,项目名称:eaEmu,代码行数:50,代码来源:wxMain.py

示例4: stopService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
    def stopService(self):
        def finish_up(d):
            self.console("mark2 stopped.")

        d = MultiService.stopService(self)
        d.addCallback(finish_up)
        return d
开发者ID:runfalk,项目名称:mark2,代码行数:9,代码来源:manager.py

示例5: setUp

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
class TestServicesBase:

    run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=5)

    def setUp(self):
        super(TestServicesBase, self).setUp()
        self.observers = theLogPublisher.observers[:]
        self.services = MultiService()
        self.services.privilegedStartService()
        self.services.startService()

    def tearDown(self):
        super(TestServicesBase, self).tearDown()
        d = self.services.stopService()
        # The log file must be read in right after services have stopped,
        # before the temporary directory where the log lives is removed.
        d.addBoth(lambda ignore: self.addDetailFromLog())
        d.addBoth(lambda ignore: self.assertNoObserversLeftBehind())
        return d

    def addDetailFromLog(self):
        content = content_from_file(self.log_filename, buffer_now=True)
        self.addDetail("log", content)

    def assertNoObserversLeftBehind(self):
        self.assertEqual(self.observers, theLogPublisher.observers)
开发者ID:cloudbase,项目名称:maas,代码行数:28,代码来源:test_services.py

示例6: stopService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
    def stopService(self):
        """
        Stop all child services, then stop the subprocess, if it's running.
        """

        if self.delayedShutdown:
            # We're still in the process of initializing the database, so
            # delay shutdown until the shutdownDeferred fires.
            d = self.shutdownDeferred = Deferred()
            d.addCallback(lambda ignored: MultiService.stopService(self))
        else:
            d = MultiService.stopService(self)

        def superStopped(result):
            # If pg_ctl's startup wasn't successful, don't bother to stop the
            # database.  (This also happens in command-line tools.)
            if self.shouldStopDatabase:

                # Compare pg_ctl inode with one we saw at the start; if different
                # (or missing), fall back to SIGTERM
                try:
                    newInode = os.stat(self._pgCtl).st_ino
                except OSError:
                    # Missing
                    newInode = -1

                if self._pgCtlInode != newInode:
                    # send SIGTERM to postgres
                    log.info("Postgres control script mismatch")
                    if self._postgresPid:
                        log.info("Sending SIGTERM to Postgres")
                        try:
                            os.kill(self._postgresPid, signal.SIGTERM)
                        except OSError:
                            pass
                    return succeed(None)
                else:
                    # use pg_ctl stop
                    monitor = PostgresMonitor()
                    args = [self._pgCtl, "stop", "--log={}".format(self.logFile)]
                    log.info("Requesting postgres stop via: {args}", args=args)
                    self.reactor.spawnProcess(
                        monitor, self._pgCtl, args, env=self.env, path=self.workingDir.path, uid=self.uid, gid=self.gid
                    )
                    return monitor.completionDeferred

        return d.addCallback(superStopped)
开发者ID:eventable,项目名称:CalendarServer,代码行数:49,代码来源:subpostgres.py

示例7: stopService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
 def stopService(self):
     """Stop listening on both ports."""
     logger.info("- - - - - SERVER STOPPING")
     yield MultiService.stopService(self)
     if self.heartbeat_writer:
         self.heartbeat_writer.loseConnection()
         self.heartbeat_writer = None
     logger.info("- - - - - SERVER STOPPED")
开发者ID:cloudfleet,项目名称:filesync-server,代码行数:10,代码来源:ssl_proxy.py

示例8: stopService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
    def stopService(self, clean_stop=False):
        # If commander was stopped manually instead of connection was lost
        if clean_stop:
            count = yield self.cl_client.user_count()
            if count:
                LOG.debug("Notifying users about quitting")
                self.cl_client.chat_all(
                    _("{commander} is quitting. Goodbye everyone!").format(
                      commander=unicode(settings.COMMANDER_NAME)))

        yield MultiService.stopService(self)
        if not self.shared_storage.flushdb():
            LOG.error("Failed to flush commander's shared storage")
开发者ID:Kamyhin,项目名称:il2ds-events-commander,代码行数:15,代码来源:__init__.py

示例9: stopService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
 def stopService(self):
     """
     Stop all child services, then stop the subprocess, if it's running.
     """
     d = MultiService.stopService(self)
     def superStopped(result):
         # Probably want to stop and wait for startup if that hasn't
         # completed yet...
         monitor = _PostgresMonitor()
         pg_ctl = which("pg_ctl")[0]
         reactor.spawnProcess(monitor, pg_ctl,
             [pg_ctl, '-l', 'logfile', 'stop'],
             self.env,
             uid=self.uid, gid=self.gid,
         )
         return monitor.completionDeferred
     return d.addCallback(superStopped)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:19,代码来源:subpostgres.py

示例10: stop

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
    def stop(self, clean=False):
        """
        Overloaded base method for stopping commander service with all its
        subservices. Call this method when connection with server is lost or
        commander is going to exit.

        Input:
        clean:  'True' if commander was stopped manually, 'False' if connection
                with server was lost.
        """
        if clean:
            count = yield self.cl_client.users_count()
            if count:
                LOG.debug("Notifying users about quitting")
                self.cl_client.chat_all(
                    _("Commander is quitting. Goodbye everyone!"))

        yield MultiService.stopService(self)
        self.confs.clear()
        self.clear_shared_storage()
开发者ID:IL2HorusTeam,项目名称:il2ds-events-commander,代码行数:22,代码来源:__init__.py

示例11: TestUDPRedirect

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
class TestUDPRedirect(TxTestCase):

    def setUp(self):
        self.service = MultiService()
        self.received = []

        class Collect(DatagramProtocol):

            def datagramReceived(cself, data, host_port):
                self.got_data(data)

        self.port = reactor.listenUDP(0, Collect())

        self.processor = TestMessageProcessor()
        self.router = Router(self.processor,
            r"any => redirect_udp 127.0.0.1 %s" %
            (self.port.getHost().port,),
            service=self.service)
        self.service.startService()
        return self.router.ready

    @defer.inlineCallbacks
    def tearDown(self):
        yield self.service.stopService()
        self.port.stopListening()

    def test_redirect(self):
        """
        Any message gets dropped with the drop rule.
        """
        message = "gorets:1|c"
        d = defer.Deferred()

        def got_data(data):
            self.assertEqual(data, message)
            d.callback(True)
        self.got_data = got_data
        self.router.process(message)
        return d
开发者ID:Weasyl,项目名称:txstatsd,代码行数:41,代码来源:test_router.py

示例12: stopService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
 def stopService(self):
     if self.parent.is_connected:
         self.cl_client.chat_all(_("Minicommander quits. Good bye!"))
     yield MultiService.stopService(self)
开发者ID:IL2HorusTeam,项目名称:minic,代码行数:6,代码来源:__init__.py

示例13: stopService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
 def stopService(self):
     d = MultiService.stopService(self)
     self.logObserver.stop()
     return d
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:6,代码来源:caldav.py

示例14: stopService

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
 def stopService(self):
     self.evt_log.setServiceParent(self)
     return MultiService.stopService(self)
开发者ID:nickmerwin,项目名称:il2ds-middleware,代码行数:5,代码来源:service.py

示例15: _main_async

# 需要导入模块: from twisted.application.service import MultiService [as 别名]
# 或者: from twisted.application.service.MultiService import stopService [as 别名]
def _main_async(reactor, argv=None, _abort_for_test=False):
    if argv is None:
        argv = sys.argv
    
    if not _abort_for_test:
        # Some log messages would be discarded if we did not set up things early.
        configure_logging()
    
    # Option parsing is done before importing the main modules so as to avoid the cost of initializing gnuradio if we are aborting early. TODO: Make that happen for createConfig too.
    argParser = argparse.ArgumentParser(prog=argv[0])
    argParser.add_argument('config_path', metavar='CONFIG',
        help='path of configuration directory or file')
    argParser.add_argument('--create', dest='createConfig', action='store_true',
        help='write template configuration file to CONFIG and exit')
    argParser.add_argument('-g, --go', dest='openBrowser', action='store_true',
        help='open the UI in a web browser')
    argParser.add_argument('--force-run', dest='force_run', action='store_true',
        help='Run DSP even if no client is connected (for debugging).')
    args = argParser.parse_args(args=argv[1:])

    # Verify we can actually run.
    # Note that this must be done before we actually load core modules, because we might get an import error then.
    version_report = yield _check_versions()
    if version_report:
        print >>sys.stderr, version_report
        sys.exit(1)

    # Write config file and exit if asked ...
    if args.createConfig:
        write_default_config(args.config_path)
        log.msg('Created default configuration at: ' + args.config_path)
        sys.exit(0)  # TODO: Consider using a return value or something instead
    
    # ... else read config file
    config_obj = Config(reactor)
    execute_config(config_obj, args.config_path)
    yield config_obj._wait_and_validate()
    
    log.msg('Constructing...')
    app = config_obj._create_app()
    
    reactor.addSystemEventTrigger('during', 'shutdown', app.close_all_devices)
    
    log.msg('Restoring state...')
    pfg = PersistenceFileGlue(
        reactor=reactor,
        root_object=app,
        filename=config_obj._state_filename,
        get_defaults=_app_defaults)
    
    log.msg('Starting web server...')
    services = MultiService()
    for maker in config_obj._service_makers:
        IService(maker(app)).setServiceParent(services)
    services.startService()
    
    log.msg('ShinySDR is ready.')
    
    for service in services:
        # TODO: should have an interface (currently no proper module to put it in)
        service.announce(args.openBrowser)
    
    if args.force_run:
        log.msg('force_run')
        from gnuradio.gr import msg_queue
        # TODO kludge, make this less digging into guts
        app.get_receive_flowgraph().monitor.get_fft_distributor().subscribe(msg_queue(limit=2))
    
    if _abort_for_test:
        services.stopService()
        yield pfg.sync()
        defer.returnValue(app)
    else:
        yield defer.Deferred()  # never fires
开发者ID:thefinn93,项目名称:shinysdr,代码行数:76,代码来源:main.py


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