Beispiel #1
0
 def test_keyboard_interrupts_propagated(self):
   condition = threading.Condition()
   condition.acquire()
   with self.assertRaises(KeyboardInterrupt):
     with temporary_dir() as rundir:
       pool = WorkerPool(WorkUnit(rundir, None, "work"), FakeRunTracker(), 1)
       try:
         pool.submit_async_work(Work(keyboard_interrupt_raiser, [()]))
         condition.wait(2)
       finally:
         pool.abort()
Beispiel #2
0
    def execute(self):
        thrift_targets = self.get_targets(self._is_thrift)
        with self.invalidated(thrift_targets) as invalidation_check:
            if not invalidation_check.invalid_vts:
                return

            with self.context.new_workunit(
                    'parallel-thrift-linter') as workunit:
                worker_pool = WorkerPool(workunit.parent,
                                         self.context.run_tracker,
                                         self.get_options().worker_count)

                scrooge_linter_classpath = self.tool_classpath(
                    'scrooge-linter')
                results = []
                errors = []
                for vt in invalidation_check.invalid_vts:
                    r = worker_pool.submit_async_work(
                        Work(self._lint,
                             [(vt.target, scrooge_linter_classpath)]))
                    results.append((r, vt))
                for r, vt in results:
                    r.wait()
                    # MapResult will raise _value in `get` if the run is not successful.
                    try:
                        r.get()
                    except ThriftLintError as e:
                        errors.append(str(e))
                    else:
                        vt.update()

                if errors:
                    raise TaskError('\n'.join(errors))
Beispiel #3
0
  def execute(self):
    if self.get_options().skip:
      return

    thrift_targets = self.context.targets(self._is_thrift)
    with self.invalidated(thrift_targets) as invalidation_check:
      if not invalidation_check.invalid_vts:
        return

      with self.context.new_workunit('parallel-thrift-linter') as workunit:
        worker_pool = WorkerPool(workunit.parent,
                                 self.context.run_tracker,
                                 self.get_options().worker_count)

        scrooge_linter_classpath = self.tool_classpath('scrooge-linter')
        results = []
        errors = []
        for vt in invalidation_check.invalid_vts:
          r = worker_pool.submit_async_work(Work(self._lint, [(vt.target, scrooge_linter_classpath)]))
          results.append((r, vt))
        for r, vt in results:
          r.wait()
          # MapResult will raise _value in `get` if the run is not successful.
          try:
            r.get()
          except ThriftLintError as e:
            errors.append(str(e))
          else:
            vt.update()

        if errors:
          raise TaskError('\n'.join(errors))
Beispiel #4
0
    def execute(self):
        thrift_targets = self.get_targets(self._is_thrift)

        task_worker_count_configured = not self.get_options().is_default(
            "worker_count")
        subsystem_worker_count_configured = not ScroogeLinter.global_instance(
        ).options.is_default("worker_count")
        if task_worker_count_configured and subsystem_worker_count_configured:
            self.raise_conflicting_option("worker_count")
        worker_count = (self.get_options().worker_count
                        if task_worker_count_configured else
                        ScroogeLinter.global_instance().options.worker_count)

        with self.invalidated(thrift_targets) as invalidation_check:
            if not invalidation_check.invalid_vts:
                return

            with self.context.new_workunit(
                    'parallel-thrift-linter') as workunit:
                worker_pool = WorkerPool(workunit.parent,
                                         self.context.run_tracker,
                                         worker_count, workunit.name)

                scrooge_linter_classpath = self.tool_classpath(
                    'scrooge-linter')
                results = []
                errors = []
                for vt in invalidation_check.invalid_vts:
                    r = worker_pool.submit_async_work(
                        Work(self._lint,
                             [(vt.target, scrooge_linter_classpath)]))
                    results.append((r, vt))
                for r, vt in results:
                    r.wait()
                    # MapResult will raise _value in `get` if the run is not successful.
                    try:
                        r.get()
                    except ThriftLintError as e:
                        errors.append(str(e))
                    else:
                        vt.update()

                if errors:
                    raise TaskError('\n'.join(errors))