本文整理汇总了Python中pants.base.run_info.RunInfo.dir方法的典型用法代码示例。如果您正苦于以下问题:Python RunInfo.dir方法的具体用法?Python RunInfo.dir怎么用?Python RunInfo.dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.base.run_info.RunInfo
的用法示例。
在下文中一共展示了RunInfo.dir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_server
# 需要导入模块: from pants.base.run_info import RunInfo [as 别名]
# 或者: from pants.base.run_info.RunInfo import dir [as 别名]
def run_server(reporting_queue):
def report_launch(actual_port):
reporting_queue.put(
'Launching server with pid %d at http://localhost:%d' % (os.getpid(), actual_port))
def done_reporting():
reporting_queue.put(DONE)
try:
# We mustn't block in the child, because the multiprocessing module enforces that the
# parent either kills or joins to it. Instead we fork a grandchild that inherits the queue
# but is allowed to block indefinitely on the server loop.
if not os.fork():
# Child process.
info_dir = RunInfo.dir(self.context.config)
# If these are specified explicitly in the config, use those. Otherwise
# they will be None, and we'll use the ones baked into this package.
template_dir = self.context.config.get('reporting', 'reports_template_dir')
assets_dir = self.context.config.get('reporting', 'reports_assets_dir')
settings = ReportingServer.Settings(info_dir=info_dir, template_dir=template_dir,
assets_dir=assets_dir, root=get_buildroot(),
allowed_clients=self.context.options.allowed_clients)
server = ReportingServer(self.context.options.port, settings)
actual_port = server.server_port()
ReportingServerManager.save_current_server_port(actual_port)
report_launch(actual_port)
done_reporting()
# Block forever here.
server.start()
except socket.error:
done_reporting()
raise
示例2: from_config
# 需要导入模块: from pants.base.run_info import RunInfo [as 别名]
# 或者: from pants.base.run_info.RunInfo import dir [as 别名]
def from_config(cls, config):
if not isinstance(config, Config):
raise ValueError('Expected a Config object, given %s of type %s' % (config, type(config)))
info_dir = RunInfo.dir(config)
stats_upload_url = config.getdefault('stats_upload_url', default=None)
num_foreground_workers = config.getdefault('num_foreground_workers', default=8)
num_background_workers = config.getdefault('num_background_workers', default=8)
return cls(info_dir,
stats_upload_url=stats_upload_url,
num_foreground_workers=num_foreground_workers,
num_background_workers=num_background_workers)