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