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


Python ReportingServerManager.save_current_server_port方法代码示例

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


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

示例1: run_server

# 需要导入模块: from pants.reporting.reporting_server import ReportingServerManager [as 别名]
# 或者: from pants.reporting.reporting_server.ReportingServerManager import save_current_server_port [as 别名]
    def run_server(reporting_queue):
      def report_launch(actual_port):
        reporting_queue.put(
          'Launching server with pid {pid} at http://localhost:{port}'
          .format(pid=os.getpid(), port=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.
          # The server finds run-specific info dirs by looking at the subdirectories of info_dir,
          # which is conveniently and obviously the parent dir of the current run's info dir.
          info_dir = os.path.dirname(self.context.run_tracker.run_info_dir)
          # 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.get_options().template_dir
          assets_dir = self.get_options().assets_dir
          settings = ReportingServer.Settings(info_dir=info_dir, template_dir=template_dir,
                                              assets_dir=assets_dir, root=get_buildroot(),
                                              allowed_clients=self.get_options().allowed_clients)
          server = ReportingServer(self.get_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
开发者ID:MathewJennings,项目名称:pants,代码行数:37,代码来源:reporting_server.py

示例2: run_server

# 需要导入模块: from pants.reporting.reporting_server import ReportingServerManager [as 别名]
# 或者: from pants.reporting.reporting_server.ReportingServerManager import save_current_server_port [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
开发者ID:Docworld,项目名称:pants,代码行数:34,代码来源:reporting_server.py


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