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


Python ExceptionalThread.daemon方法代码示例

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


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

示例1: main

# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import daemon [as 别名]
def main(_, options):
  observer = initialize(options)
  observer.start()
  root_server = configure_server(observer)

  thread = ExceptionalThread(target=lambda: root_server.run(options.ip, options.port, 'cherrypy'))
  thread.daemon = True
  thread.start()

  sleep_forever()
开发者ID:bmhatfield,项目名称:aurora,代码行数:12,代码来源:thermos_observer.py

示例2: main

# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import daemon [as 别名]
  def main(_, opts):
    path_detector = FixedPathDetector(opts.root)
    task_observer = TaskObserver(path_detector)
    task_observer.start()
    server = configure_server(task_observer)

    thread = ExceptionalThread(target=lambda: server.run('0.0.0.0', opts.port, 'cherrypy'))
    thread.daemon = True
    thread.start()

    sleep_forever()
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:13,代码来源:thermos_observer.py

示例3: main

# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import daemon [as 别名]
    def main(args, opts):
        """Main"""
        server = RedirServer(opts.zk_basepath,
                             opts.subdomain,
                             opts.base_domain)
        thread = ExceptionalThread(
            target=lambda: server.run(opts.listen,
                                      opts.port,
                                      server='cherrypy'))
        thread.daemon = True
        thread.start()

        wait_forever()
开发者ID:thinker0,项目名称:aurora-jobhopper,代码行数:15,代码来源:__main__.py

示例4: main

# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import daemon [as 别名]
def main(_, options):
  path_detector = ChainedPathDetector(
      FixedPathDetector(options.root),
      MesosPathDetector(options.mesos_root),
  )
  observer = TaskObserver(path_detector)
  observer.start()
  root_server = configure_server(observer)

  thread = ExceptionalThread(target=lambda: root_server.run('0.0.0.0', options.port, 'cherrypy'))
  thread.daemon = True
  thread.start()

  sleep_forever()
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:16,代码来源:thermos_observer.py

示例5: main

# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import daemon [as 别名]
    def main(args, opts):
        """Main"""
        zkconn = kazoo_client.TwitterKazooClient(opts.zk)
        zkconn.start()

        server = RedirServer(zkconn, opts.zk_basepath, opts.scheduler_url,
                             opts.subdomain, opts.base_domain)
        thread = ExceptionalThread(
            target=lambda: server.run(opts.listen,
                                      opts.port,
                                      server='cherrypy'))
        thread.daemon = True
        thread.start()

        # Wait forever, basically.
        thread.join()
开发者ID:SEJeff,项目名称:aurora-jobhopper,代码行数:18,代码来源:jobhopper.py

示例6: main

# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import daemon [as 别名]
    def main(_, opts):
        """Main"""

        if not opts.bucket:
            log.error('--bucket is required.')
            app.help()

        server = S3Web(bucket=opts.bucket,
                       prefix=opts.prefix,
                       access_key_id=opts.access_key_id,
                       secret_key=opts.secret_key)
        thread = ExceptionalThread(
            target=lambda: server.run(opts.listen,
                                      opts.port,
                                      server='cherrypy'))
        thread.daemon = True
        thread.start()

        log.info('Ready.')
        app.wait_forever()
开发者ID:benley,项目名称:s3webfront,代码行数:22,代码来源:s3webfront.py

示例7: main

# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import daemon [as 别名]
def main(args, opts):
  if args:
    print("ERROR: unrecognized arguments: %s\n" % (" ".join(args)), file=sys.stderr)
    app.help()
    sys.exit(1)

  root_server = HttpServer()
  root_server.mount_routes(DiagnosticsEndpoints())

  task_observer = TaskObserver(opts.root)
  task_observer.start()

  bottle_wrapper = BottleObserver(task_observer)

  root_server.mount_routes(bottle_wrapper)

  def run():
    root_server.run('0.0.0.0', opts.port, 'cherrypy')

  et = ExceptionalThread(target=run)
  et.daemon = True
  et.start()
  et.join()
开发者ID:calebTomlinson,项目名称:aurora,代码行数:25,代码来源:thermos_observer.py

示例8: main

# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import daemon [as 别名]

#.........这里部分代码省略.........

    fw_principal = None
    fw_secret = None
    if options.framework_authentication_file:
      try:
        with open(options.framework_authentication_file, "r") as f:
          cred = yaml.load(f)
        fw_principal = cred["principal"]
        fw_secret = cred["secret"]
        log.info("Loaded credential (principal=%s) for framework authentication" % fw_principal)
      except IOError as e:
        app.error("Unable to read the framework authentication key file: %s" % e)
      except (KeyError, yaml.YAMLError) as e:
        app.error("Invalid framework authentication key file format %s" % e)

    log.info("Starting Mysos scheduler")

    kazoo = KazooClient(zk_servers)
    kazoo.start()

    if options.state_storage == 'zk':
      log.info("Using ZooKeeper (path: %s) for state storage" % zk_root)
      state_provider = ZooKeeperStateProvider(kazoo, zk_root)
    else:
      log.info("Using local disk for state storage")
      state_provider = LocalStateProvider(options.work_dir)

    try:
      state = state_provider.load_scheduler_state()
    except StateProvider.Error as e:
      app.error(e.message)

    if state:
      log.info("Successfully restored scheduler state")
      framework_info = state.framework_info
      if framework_info.HasField('id'):
        log.info("Recovered scheduler's FrameworkID is %s" % framework_info.id.value)
    else:
      log.info("No scheduler state to restore")
      framework_info = FrameworkInfo(
          user=options.framework_user,
          name=FRAMEWORK_NAME,
          checkpoint=True,
          failover_timeout=framework_failover_timeout.as_(Time.SECONDS),
          role=options.framework_role)
      if fw_principal:
        framework_info.principal = fw_principal
      state = Scheduler(framework_info)
      state_provider.dump_scheduler_state(state)

    scheduler = MysosScheduler(
        state,
        state_provider,
        options.framework_user,
        options.executor_uri,
        options.executor_cmd,
        kazoo,
        options.zk_url,
        election_timeout,
        options.admin_keypath,
        installer_args=options.installer_args,
        backup_store_args=options.backup_store_args,
        executor_environ=options.executor_environ,
        framework_role=options.framework_role)

    if fw_principal and fw_secret:
      cred = Credential(principal=fw_principal, secret=fw_secret)
      scheduler_driver = mesos.native.MesosSchedulerDriver(
          scheduler,
          framework_info,
          options.mesos_master,
          cred)
    else:
      scheduler_driver = mesos.native.MesosSchedulerDriver(
          scheduler,
          framework_info,
          options.mesos_master)

    scheduler_driver.start()

    server = HttpServer()
    server.mount_routes(MysosServer(scheduler, web_assets_dir))

    et = ExceptionalThread(
        target=server.run, args=('0.0.0.0', options.api_port, 'cherrypy'))
    et.daemon = True
    et.start()

    try:
      # Wait for the scheduler to stop.
      # The use of 'stopped' event instead of scheduler_driver.join() is necessary to stop the
      # process with SIGINT.
      while not scheduler.stopped.wait(timeout=0.5):
        pass
    except KeyboardInterrupt:
      log.info('Interrupted, exiting.')
    else:
      log.info('Scheduler exited.')

    app.shutdown(1)  # Mysos scheduler is supposed to be long-running thus the use of exit status 1.
开发者ID:gpapilion,项目名称:mysos,代码行数:104,代码来源:mysos_scheduler.py


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