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


Python monitor.TaskMonitor类代码示例

本文整理汇总了Python中apache.thermos.monitoring.monitor.TaskMonitor的典型用法代码示例。如果您正苦于以下问题:Python TaskMonitor类的具体用法?Python TaskMonitor怎么用?Python TaskMonitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: add_active_task

 def add_active_task(self, task_id):
     if task_id in self.finished_tasks:
         log.error("Found an active task (%s) in finished tasks?" % task_id)
         return
     task_monitor = TaskMonitor(self._pathspec, task_id)
     if not task_monitor.get_state().header:
         log.info('Unable to load task "%s"' % task_id)
         return
     sandbox = task_monitor.get_state().header.sandbox
     resource_monitor = self._resource_monitor(task_monitor, sandbox)
     resource_monitor.start()
     self._active_tasks[task_id] = ActiveObservedTask(
         task_id=task_id, pathspec=self._pathspec, task_monitor=task_monitor, resource_monitor=resource_monitor
     )
开发者ID:retrack,项目名称:incubator-aurora,代码行数:14,代码来源:task_observer.py

示例2: test_coordinator_dead_kill

  def test_coordinator_dead_kill(self):
    runner = self.start_runner()
    tm = TaskMonitor(runner.pathspec, runner.task_id)
    self.wait_until_running(tm)
    process_state, run_number = tm.get_active_processes()[0]
    assert process_state.process == 'ignorant_process'
    assert run_number == 0

    os.kill(runner.po.pid, signal.SIGKILL)
    os.kill(process_state.coordinator_pid, signal.SIGKILL)
    os.kill(process_state.pid, signal.SIGKILL)

    killer = TaskRunner.get(runner.task_id, runner.root)
    assert killer is not None
    killer.kill(force=True)

    state = tm.get_state()
    assert len(state.processes['ignorant_process']) == 1
    assert state.processes['ignorant_process'][0].state == ProcessState.LOST
开发者ID:bhuvan,项目名称:incubator-aurora,代码行数:19,代码来源:test_staged_kill.py

示例3: test_basic

    def test_basic(self):
        proxy_driver = ProxyDriver()

        with temporary_dir() as tempdir:
            te = AuroraExecutor(runner_provider=make_provider(tempdir), sandbox_provider=DefaultTestSandboxProvider())
            te.launchTask(proxy_driver, make_task(HELLO_WORLD_MTI))
            te.terminated.wait()
            tm = TaskMonitor(tempdir, task_id=HELLO_WORLD_TASK_ID)
            runner_state = tm.get_state()

        assert "hello_world_hello_world-001" in runner_state.processes, "Could not find processes, got: %s" % " ".join(
            runner_state.processes
        )

        updates = proxy_driver.method_calls["sendStatusUpdate"]
        assert len(updates) == 3
        status_updates = [arg_tuple[0][0] for arg_tuple in updates]
        assert status_updates[0].state == mesos_pb2.TASK_STARTING
        assert status_updates[1].state == mesos_pb2.TASK_RUNNING
        assert status_updates[2].state == mesos_pb2.TASK_FINISHED
开发者ID:rosmo,项目名称:aurora,代码行数:20,代码来源:test_thermos_executor.py

示例4: test_preemption_wait

  def test_preemption_wait(self):
    runner = self.start_runner()
    tm = TaskMonitor(runner.pathspec, runner.task_id)
    self.wait_until_running(tm)
    process_state, run_number = tm.get_active_processes()[0]
    assert process_state.process == 'ignorant_process'
    assert run_number == 0

    preempter = TaskRunner.get(runner.task_id, runner.root)
    assert preempter is not None
    now = time.time()
    preempter.kill(force=True, preemption_wait=Amount(1, Time.SECONDS))
    duration = time.time() - now

    # This is arbitrary, but make sure we finish within half a second of
    # requested preemption wait.
    assert abs(duration - 1.0) < 0.5

    assert preempter.state.statuses[-1].state == TaskState.KILLED
    assert preempter.state.processes['ignorant_process'][-1].state == ProcessState.KILLED
开发者ID:bhuvan,项目名称:incubator-aurora,代码行数:20,代码来源:test_staged_kill.py

示例5: test_coordinator_kill

  def test_coordinator_kill(self):
    runner = self.start_runner()
    tm = TaskMonitor(runner.pathspec, runner.task_id)
    self.wait_until_running(tm)

    process_state, run_number = tm.get_active_processes()[0]
    assert process_state.process == 'process'
    assert run_number == 0
    os.kill(process_state.coordinator_pid, signal.SIGKILL)

    while True:
      if not hasattr(runner, 'state'):
        time.sleep(0.1)
      else:
        break

    assert runner.state.statuses[-1].state == TaskState.SUCCESS
    assert 'process' in runner.state.processes
    assert len(runner.state.processes['process']) == 2
    assert runner.state.processes['process'][0].state == ProcessState.LOST
    assert runner.state.processes['process'][1].state == ProcessState.SUCCESS
开发者ID:bhuvan,项目名称:incubator-aurora,代码行数:21,代码来源:test_staged_kill.py

示例6: test_process_kill

    def test_process_kill(self):
        runner = self.start_runner()
        tm = TaskMonitor(runner.tempdir, runner.task_id)
        self.wait_until_running(tm)

        process_state, run_number = tm.get_active_processes()[0]
        assert process_state.process == "process"
        assert run_number == 0
        os.kill(process_state.pid, signal.SIGKILL)

        while True:
            if not hasattr(runner, "state"):
                time.sleep(0.1)
            else:
                break

        assert runner.state.statuses[-1].state == TaskState.SUCCESS
        assert "process" in runner.state.processes
        assert len(runner.state.processes["process"]) == 2
        assert runner.state.processes["process"][0].state == ProcessState.KILLED
        assert runner.state.processes["process"][0].return_code == -signal.SIGKILL
        assert runner.state.processes["process"][1].state == ProcessState.SUCCESS
开发者ID:bmhatfield,项目名称:aurora,代码行数:22,代码来源:test_staged_kill.py

示例7: test_basic_as_job

  def test_basic_as_job(self):
    proxy_driver = ProxyDriver()

    with temporary_dir() as tempdir:
      te = AuroraExecutor(
          runner_provider=make_provider(tempdir),
          sandbox_provider=DefaultTestSandboxProvider())
      te.launchTask(proxy_driver, make_task(MESOS_JOB(task=HELLO_WORLD), instanceId=0))
      te.runner_started.wait()
      while te._status_manager is None:
        time.sleep(0.1)
      te.terminated.wait()
      tm = TaskMonitor(tempdir, task_id=HELLO_WORLD_TASK_ID)
      runner_state = tm.get_state()

    assert 'hello_world_hello_world-001' in runner_state.processes, (
      'Could not find processes, got: %s' % ' '.join(runner_state.processes))
    updates = proxy_driver.method_calls['sendStatusUpdate']
    assert len(updates) == 3
    status_updates = [arg_tuple[0][0] for arg_tuple in updates]
    assert status_updates[0].state == mesos_pb2.TASK_STARTING
    assert status_updates[1].state == mesos_pb2.TASK_RUNNING
    assert status_updates[2].state == mesos_pb2.TASK_FINISHED
开发者ID:bmhatfield,项目名称:aurora,代码行数:23,代码来源:test_thermos_executor.py

示例8: test_pg_is_killed

  def test_pg_is_killed(self):
    runner = self.start_runner()
    tm = TaskMonitor(runner.pathspec, runner.task_id)
    self.wait_until_running(tm)
    process_state, run_number = tm.get_active_processes()[0]
    assert process_state.process == 'process'
    assert run_number == 0

    child_pidfile = os.path.join(runner.sandbox, runner.task_id, 'child.txt')
    while not os.path.exists(child_pidfile):
      time.sleep(0.1)
    parent_pidfile = os.path.join(runner.sandbox, runner.task_id, 'parent.txt')
    while not os.path.exists(parent_pidfile):
      time.sleep(0.1)
    with open(child_pidfile) as fp:
      child_pid = int(fp.read().rstrip())
    with open(parent_pidfile) as fp:
      parent_pid = int(fp.read().rstrip())

    ps = ProcessProviderFactory.get()
    ps.collect_all()
    assert parent_pid in ps.pids()
    assert child_pid in ps.pids()
    assert child_pid in ps.children_of(parent_pid)

    with open(os.path.join(runner.sandbox, runner.task_id, 'exit.txt'), 'w') as fp:
      fp.write('go away!')

    while tm.task_state() is not TaskState.SUCCESS:
      time.sleep(0.1)

    state = tm.get_state()
    assert state.processes['process'][0].state == ProcessState.SUCCESS

    ps.collect_all()
    assert parent_pid not in ps.pids()
    assert child_pid not in ps.pids()
开发者ID:bhuvan,项目名称:incubator-aurora,代码行数:37,代码来源:test_staged_kill.py


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