本文整理汇总了Python中twitter.common.exceptions.ExceptionalThread.start方法的典型用法代码示例。如果您正苦于以下问题:Python ExceptionalThread.start方法的具体用法?Python ExceptionalThread.start怎么用?Python ExceptionalThread.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.common.exceptions.ExceptionalThread
的用法示例。
在下文中一共展示了ExceptionalThread.start方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [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()
示例2: main
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [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()
示例3: main
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [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()
示例4: main
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [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()
示例5: test_quitquitquit
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [as 别名]
def test_quitquitquit():
def main():
app.wait_forever()
def wait_and_quit():
time.sleep(0.5)
app.quitquitquit()
stop_thread = ExceptionalThread(target=wait_and_quit)
stop_thread.start()
app = TestApplication(main)
app.main()
assert app.exited_rc == 0
示例6: main
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [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()
示例7: main
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [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()
示例8: main
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [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()
示例9: start
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [as 别名]
def start(self):
ExceptionalThread.start(self)
示例10: main
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [as 别名]
def main(args, options):
log.info("Options in use: %s", options)
if not options.api_port:
app.error('Must specify --port')
if not options.mesos_master:
app.error('Must specify --mesos_master')
if not options.framework_user:
app.error('Must specify --framework_user')
if not options.executor_uri:
app.error('Must specify --executor_uri')
if not options.executor_cmd:
app.error('Must specify --executor_cmd')
if not options.zk_url:
app.error('Must specify --zk_url')
if not options.admin_keypath:
app.error('Must specify --admin_keypath')
try:
election_timeout = parse_time(options.election_timeout)
framework_failover_timeout = parse_time(options.framework_failover_timeout)
except InvalidTime as e:
app.error(e.message)
try:
_, zk_servers, zk_root = zookeeper.parse(options.zk_url)
except Exception as e:
app.error("Invalid --zk_url: %s" % e.message)
web_assets_dir = os.path.join(options.work_dir, "web")
pkgutil.unpack_assets(web_assets_dir, MYSOS_MODULE, ASSET_RELPATH)
log.info("Extracted web assets into %s" % options.work_dir)
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,
#.........这里部分代码省略.........
示例11: start
# 需要导入模块: from twitter.common.exceptions import ExceptionalThread [as 别名]
# 或者: from twitter.common.exceptions.ExceptionalThread import start [as 别名]
def start(self):
StatusChecker.start(self)
ExceptionalThread.start(self)